2-Mavzu: Структуралар ва рўйхатлар.
Strukturani e’lon etish.
struct Simple {
public int Position;
public bool Exists;
public double LastValue;
};
static void Main() {
// Step 1: create struct on stack. Simple s;
s.Position = 1;
s.Exists = false;
s.LastValue = 5.5;
// Step 2: write struct field.
Console.WriteLine(s.Position);
}
Strukturada xususiyatlardan foydalanish.
static void Main() {
// Initialize to 0.
S st = new S();
st.X = 5;
Console.WriteLine(st.X);
}
struct S {
int _x;
public int X {
get { return _x; }
set { if (value < 10) { _x = value; } }
}
};
Class va strukturadan foydalanish.
Websaytlarda strukturalardan foydalanish.
Do'stlaringiz bilan baham: |