Skip to content
List of chapters in c# tutorial.
The for loop is one of the available loops in C sharp programming language. The for loop is used to execute a given block of code repeatedly to the given number of times.
The C# while loop is one of the available loops in the C Sharp like in other programming languages. The while loop executes the given statement or block of code repeatedly until the given condition is true.
The switch statement is a decision-making statement which is used to execute a block of code when you have various blocks in C# program. The C# switch is useful when you have long blocks of if, if..else statement, otherwise.
The if is a decision-making statement in C# programming which is used to execute a block of code if a given condition evaluates as true.
In other words, if you have more…
A string is a sequence of characters where each character is Unicode character. For example “This is c# programming tutorial” is a simple string.
A C# ArrayList is a class of System.Collection namespace which is just like arrays. However unlike simple arrays the ArrayList in c# is dynamic. That means you can add or remove elements from array list by using index number dynamically. While arrays are fixed in size. The ArrayList dynamically resizes itself as items are added or removed. Also ArrayList can contain mixed items like numbers and strings etc. in a single ArrayList.
The foreach is used to loop through arrays or collection like lists. The foreach loop is used with c# in statement. This makes process of looping through array or collection elements much simpler. You can use for or while loop as well to iterate through elements however foreach c# is built specifically for arrays or collection to perform desired operation in arrays. You should use c# foreach loop to get information in arrays or collection and not to change the content to avoid unpredictable things.
A C# array is a collection of similar type variables which is fixed in size. To understand array consider this example. If you have to store US state names in variables then you have to create 52 variables like that:
The list is a collection of elements or variables in specified order. The difference between array and list in C# is that list is dynamic sized whereas arrays are fixed.