How to Check if File Exists in C Sharp/C# ?
Hi, Use the following simple lines of code to check whether a particular file exists or not using C#/C Sharp. It will return either True or False depending on whether your file exists or not. ๐
Hi, Use the following simple lines of code to check whether a particular file exists or not using C#/C Sharp. It will return either True or False depending on whether your file exists or not. ๐
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 »
Hi, Use the following code if you want to reverse the digits of a number using C Sharp/C #. Output : Given Number: 123 Reversed Number: 321 ๐
Hi, For replacing a substring in C Sharp/C#, use the following lines of code.
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 »
Hi, As you know an exception is an error that occurs during the runtime. Here is a simple exception handling example using C Sharp/C#. ๐
Hi, This is how you can simply rename a namespace in C Sharp/C#, This will print out ‘Hello’! ๐
Hi, Sometimes you need to check for whether the given string is Palindrome or not. Given below is a sample code to check whether the given string is Palindrome or not using C Sharp/C#. ๐
Hi, For copying a file using FileInfo in C Sharp/C#, use the following code. For copying a file without using file info check the example given here. ๐
Hi, Use the following code example to read a complete text file using C Sharp/C#.
Hi, Use the following example code, if you want to write to a text file using C Sharp/C#. ๐
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 »
Hi, Sometimes you may need to check whether two strings are equal or not equal by checking case insensitive. See the example below to see how to achieve the same using C Sharp /C#. Output : heaven and HEAVEN are equal – Case Insensitive! ๐
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 »
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 »
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. ๐