Sample.Length = 20;
Sample m = new Sample(); m.Length = 10;
Console.WriteLine(Sample.Length);
Sample m = new Sample(); int len; len = m.Length;
Sample m = new Sample(); m.Length = m.Length + 20;
Sample m = new Sample();
m.Length = 10;
Sample m = new Sample();
m.Length = m.Length + 20;
Sample m = new Sample();
int l;
l = m.Length;
Sample.Length = 20;
Console.WriteLine(Sample.Length);
Sample m = new Sample();
int l;
l = m.Length;
class Student
{
int[] scores = new int[5] {3, 2, 4,1, 5};
public int this[ int index ]
{
set
{
if (index < 5)
scores[index] = value;
else
Console.WriteLine("Invalid Index");
}
}
}
class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index"); return 0;
}
}
set
{
if (index < 5)
scores[ index ] = value;
else
Console.WriteLine("Invalid Index");
}
}
}
class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index");
return 0;
}
}
}
}
class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
scores[ index ] = value;
else
{
Console.WriteLine("Invalid Index");
}
}
set
{
if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index");
return 0;
}
}
}
}
class Student
{
int[] scores = new int[5] {3, 2, 4, 1, 5};
public int this[ int index ]
{
get
{
if (index < 5)
return scores[ index ];
else
{
Console.WriteLine("Invalid Index"); return 0;
}
}
set
{
if (index < 5)
scores[ index ] = value;
else
Console.WriteLine("Invalid Index");
}
}
}
using System; namespace CuriousTabConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 55; int[] a = new int[5]; try { Console.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format "); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program "); } } }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.