Tag Archives: C Sharp

Get characters in a string – C Sharp/C#

By | April 7, 2012

Hi, Sometimes you may need to get all the characters in a string using C Sharp/C#. The following code gives you an example of how to get or display all the characters of a given string. Output: sampleString[0] = I sampleString[1] = sampleString[2] = L sampleString[3] = o sampleString[4] = v sampleString[5] = e sampleString[6]โ€ฆ Read More »

Sort elements in a String Array – C Sharp / C#

By | June 21, 2011

Hi, In order to sort the elements in a string array in C Sharp/C#, we use the sort() method. Given below is a simple example using sort() method to sort the elements in a string array. It will print out, Sorted string Array: urStringArray[0] = apple urStringArray[1] = coderz urStringArray[2] = heaven123 urStringArray[3] = heaven777โ€ฆ Read More »

C Sharp/C# – String Uppercase/Lowercase Conversion

By | April 28, 2011

Hi, It will be very useful to know how you can convert a given string into uppercase or lowercase using program. We are going to show you , how to convert a given string into uppercase or lowercase using C Sharp/C#. See the example given below. Output : Lowercase of sampleString : coderzheaven Uppercase ofโ€ฆ Read More »

Program to generate Fibonacci series in C Sharp/C#

By | April 27, 2011

Hi, Here is a simple program to generate Fibonacci series using C Sharp /C#. It will generate Fibonacci numbers < 100. [csharp] class MainClass { public static void Main() { int oldNum = 1; int presentNum = 1; int nextNum; System.Console.Write(presentNum + ","); while (presentNum < 100) { System.Console.Write(presentNum + ","); nextNum = presentNum +โ€ฆ Read More »

Get files from a directory – C#/C Sharp

By | April 25, 2011

Hi, Sometimes you may need to get the files from a specified directory using C# / C Sharp. See the sample code on how it works. using System; using System.IO; class MainClass { public static void Main() { string[] yourFiles = Directory.GetFiles("c:"); foreach (string fNames in yourFiles) Console.WriteLine(fNames); } } This code will get youโ€ฆ Read More »

C#/C Sharp – Delete file in a folder

By | April 25, 2011

Hi, Let’s see a simple example of deleting a file in a folder using c#. using System; using System.IO; public class MainClass { static void Main(string[] args) { FileInfo sampleFile= new FileInfo(@"c:SamplestestFile.txt"); sampleFile.Create(); sampleFile.Delete(); } } sampleFile.Create() will create the file in the specified folder. sampleFile.Delete() will delete the file in the specified folder. ๐Ÿ™‚