CSharp examples for Custom Type:Field
Create a class with two data members
using System;//from w w w . j a v a2 s . c o m class die { public int sides; public int value; } class diceApp { public static void Main() { die dice1 = new die(); die dice2 = new die(); dice1.sides = 6; dice2.sides = 12; Random rnd = new Random(); dice1.value = (int) ((rnd.NextDouble() * dice1.sides) + 1); dice2.value = (int) ((rnd.NextDouble() * dice2.sides) + 1); Console.WriteLine("dice 1; sides = {0}, value = {1}", dice1.sides, dice1.value); Console.WriteLine("dice 2; sides = {0}, value = {1}", dice2.sides, dice2.value); } }