Tag: C#

How to Generate Unique ID in C# ?

Do you want to generate a unique id in C# ? . You can use Guid to generate unique data or ID. Below is a sample code snippet that demonstrates how to generate unique ID in C# . How to Generate Unique ID in C# ?

How to Get the Application’s path in Windows or Console Application in C#?

There are times when you want to retrieve the application’s path where the exe is running to get access to another file or accessing the configuration file etc. Below is a sample program that demonstrates how one can retrieve the Application’s path in Windows or Console Application in C#. How to Get the Application’s path in Windows or Console Application in C#?

Arithmetic Operators in C#

The following Arithmetic Operators are supported in C# + (Addition) – (Subtraction) / (Division) * (Multiplication) ++ (Increment) — (Decrement) % (Modulus) Below is a sample code snippet demonstrating the usage of Arithmetic operators in C#

C# and Lambda – Finding all the elements of an integer array less than 35

Here’s a sample code snippet demonstrating how to find all the elements of an integer array that is less than 35 using Lambda expression in C#. The Where keyword in C# is used to filter the elements from a collection based on the specified criteria. How to find all the elements of an integer array less than 35 using Lambda expression in C# ? The…

Comparing only Date in the DateTime datatype in C#

The DateTime datatype includes both the date as well as the time component to it in C#. By any chance , if you want to compare only the date part in the DateTime variable in C# , you can use the Date property defined in the DateTime class. How to compare only Date in the DateTime datatype in C# ?

How to generate C# classes from xsd file ?

You can easily generate the C# classes or entities from the xsd file using the VS Command Prompt. How to generate C# classes from xsd file ? Just launch the VS command prompt from the Windows 10 Start menu and run the following command xsd <Path of your.xsd file> /classes Eg : xsd “C:/test.xsd” /classes This would create the .cs files in the same folder…

What is the default modifier for the class in C#?

What is the default modifier for the class in C#? In C#, the default modifier for the class is internal. This is applicable of there is no modifier defined for the class. When the class is internal, then it is visible only within the current assembly.

Converting an Enum to Integer in C#

If you need to convert an enum to its numeric equivalent , you can simply cast the values to integer . Below is a sample code snippet that demonstrates how to do it. Converting an Enum to Integer in C#

How to Allow Null Values for Integer in C# ?

In order to allow null values to an integer or for any value types , we need to make the data type as Nullable<T> where T refers to type. How to Allow Null Values for Integer in C# ? There are 2 ways you can set null value to value types in C# .

How to Combine a Filename with a Directory in C# ?

If you need to combine the filename with a directory name in C# , use the built in Path class to do it instead of doing it manually. How to Combine a Filename with a Directory in C# ? Below is a sample code snippet demonstrating how to use Path.Combine method in C#.

How to Pass Method or Function as Parameter in C# ?

The C# 3.0 and higher version provides the option for the user to specify the function or method as parameter using the Func delegate . How to Pass Method or Function as Parameter in C# ? Below is a sample code snippet demonstrating how to pass method as parameter in C# using Func delegate.

Params in C#

The Params keyword in C# lets the developers to specify parameter for the method that can take variable no. of arguments . For example In the above sourcecode , the method Data accepts the parameter integer array . since the parameter is marked as params , you could call the function Data with the comma seperated value like below

How to send SMS in Windows Phone 8 Programatically using C#?

In Windows Phone, the developers can send SMS from their Windows Phone 8 Programatically using the launchers. The Windows Phone SDK provides the SMSComposeTask launcher which can be used to send SMS in Windows Phone 8. Below is a code snippet demonstrating the usage of the SMSComposeTask to send SMS in Windows Phone 8. How to send SMS in Windows Phone 8 Programatically using C#?