Suggested Videos
Part 5 - Operators
Part 6 - Nullable Types
Part 7 - Datatype Conversions
In this video, we will discuss
1. Arrays
2. Advantages and dis-advantages of arrays
An array is a collection of similar data types.
using System;
class Program
{
public static void Main()
{
// Initialize and assign values in different lines
int[] EvenNumbers = new int[3];
EvenNumbers[0] = 0;
EvenNumbers[1] = 2;
EvenNumbers[2] = 4;
// Initialize and assign values in the same line
int[] OddNumbers = { 1, 3, 5};
Console.WriteLine("Printing EVEN Numbers");
// Retrieve and print even numbers from the array
for (int i = 0; i < EvenNumbers.Length; i++)
{
Console.WriteLine(EvenNumbers[i]);
}
Console.WriteLine("Printing ODD Numbers");
// Retrieve and print odd numbers from the array
for (int i = 0; i < OddNumbers.Length; i++)
{
Console.WriteLine(OddNumbers[i]);
}
}
}
Advantages: Arrays are strongly typed.
Disadvantages: Arrays cannot grow in size once initialized. Have to rely on integral indices to store or retrieve items from the array.
Part 5 - Operators
Part 6 - Nullable Types
Part 7 - Datatype Conversions
In this video, we will discuss
1. Arrays
2. Advantages and dis-advantages of arrays
An array is a collection of similar data types.
using System;
class Program
{
public static void Main()
{
// Initialize and assign values in different lines
int[] EvenNumbers = new int[3];
EvenNumbers[0] = 0;
EvenNumbers[1] = 2;
EvenNumbers[2] = 4;
// Initialize and assign values in the same line
int[] OddNumbers = { 1, 3, 5};
Console.WriteLine("Printing EVEN Numbers");
// Retrieve and print even numbers from the array
for (int i = 0; i < EvenNumbers.Length; i++)
{
Console.WriteLine(EvenNumbers[i]);
}
Console.WriteLine("Printing ODD Numbers");
// Retrieve and print odd numbers from the array
for (int i = 0; i < OddNumbers.Length; i++)
{
Console.WriteLine(OddNumbers[i]);
}
}
}
Advantages: Arrays are strongly typed.
Disadvantages: Arrays cannot grow in size once initialized. Have to rely on integral indices to store or retrieve items from the array.
i like your videos . they really helped me alot
ReplyDeleteCan you please explain the params type arrays?
ReplyDeleteSee Part 17 method parameters
Deleteits very help full to who don't have money to learn languages....thank you venkat sir. thank you soo much.
ReplyDeleteThank you so much Sir Venkat ! Your tutorials are very awesome :-)
ReplyDeleteThank you so much sir....You've really been helping me a lot and i appreciate it.
ReplyDeletehello I really like the way you teach .
ReplyDeleteI am new to c# .you have not written Console.ReadLine in any of your video without that we cannot see the output .May I know the reason behind that ?? I need to complete the c# course before april 20 .I am doing that from your videos but I need to do practice as well .Is it possible for you to give me practice examples or teach on skype on payable basis .The reason on skype is I am in Toronto can't attend your course personally.
Thanks
why we use int[] and new int[]? what [] do ?
ReplyDeleteint[]->It indicates that we are initializing array
Delete= new int[] -> it indicates that we are allocating size to array
[] is a symbol for array .. [] sign tells the compiler that we are going to make an array.
DeleteWhat about types of arrays
ReplyDeleteLet me know what is strongly typed or why arrays are strongly typed?
ReplyDeleteStrongly typed means that an Array can hold only specific datatype values in an array variable in which you cannot add any other value other than the specified datatype values.
DeleteFor instance, int[] intArr = new int[3];
You can specify intArr[1]=1233;
If you try to assign intArr[1] = "YourName"
you will be prompted with Compiler error.