Tag: C#
How to disable editing of items in a combo box in c#?
When working in Win forms using C# and especially when you use the combo box , you would have noticed that by default the user can edit the values inside during the runtime. How to disable editing of items in a combo box in c# (win forms) ? Assuming that the combobox name is combobox1 , here the code to get this behavior.
How to Check if the Enum Value is Defined in C# ?
There are times when it is necessary to check if the constant name or numeric value is defined in the Enum . We can use the Enum.IsDefined method to verify this. How to Check if the Enum Value is Defined in C# ? Below is a sample code to demonstrate how to Check if the Enum Value is Defined in C# using Enum.IsDefined method. The…
How to Extract number from a string using C# ?
Regular expression lets you to do some of the tasks quickly in C# and now such of the task that can be done using the Regex class is to extract number from a string using C# .
How to retrieve integer value and remove all other strings in C# ?
If you want to retrieve the integer value and remove all other strings in C# , one can use the Regex.Replace method and apply regular expression easily and get only the integer part from a string. How to How to retrieve integer value and remove all other strings in C# ? Below is a sample sourecode demonstrating How to retrieve integer value and remove all…
How to Apply LINQ Distinct on a particular property in C#?
Do you want to get the distinct records from a list based on a particular property using LINQ in C#?. Below is a code snippet that demonstrates how to do it. How to Apply LINQ Distinct on a particular property in C#?
How to enforce the Garbage Collection in C# ?
You can enforce the garbage collection in C# using System.GC.Collect();
How to Get the Property value using reflection in C# ?
Below is a sample method that demonstrates how to retrieve the property value in C# using reflection. How to Get the Property value using reflection in C# ?
How to Get the Last N Elements from a List using LINQ in C#?
Below is a sample code snippet demonstrating how to retrieve last N Elements (2) from a list in C# using LINQ.
What is the default modifier for the class member in C#?
What is the default modifier for the class member in C#? In C#, the default modifier for the class member is private. The member in this case will be visible only within the current class.
What are the difference between class and structure in C#?
What are the difference between class and structure in C#? Structure Struct are value types. They can be empty but a null cannot be assigned to Struct Structs cannot contain explicit parameterless constructors. Doesn’t support Inheritance and cannot use the protected or protected internal modifier. A Struct always has a built-in public default constructor. Cannot use the “as” operator. Cannot have a destructor Cannot be…
Deferred Execution Example in LINQ and C#
The Query Operators are executed only when enumerated except few scenarios. For example, when you use the for/Foreach statement and iterate the items from the query result. Below is a sample code demonstrating the Deferred Execution in C#. Deferred Execution Example in LINQ and C#
How to detect if the Windows Phone App is running in KidsCorner using C#?
Below is a sample code snippet that demonstrates how to detect if the application in Windows Phone is running in Kids Corner using C#? The Windows.Phone.ApplicationModel.ApplicationProfile returns the value Default or Alternate. The default value indicates the normal mode whereas the Alternate indicates the Kids Corner mode. How to detect if the Windows Phone App is running in KidsCorner using C#?
How to List out Even Numbers from a List of Integers using LINQ in C#?
Below is sample code snippet that demonstrates how to list out only even numbers from a list of integers using LINQ? How to List out Even Numbers from a List of Integers using LINQ in C#?
Example of Immediate Query Execution of LINQ in C# .NET
Below is a sample code snippet that demonstrates the Immediate Query execution of LINQ Query in C#. Example of Immediate Query Execution of LINQ in C# .NET The Output of the above program in
How to validate a user in Active Directory using C#?
Do you want to validate a user with the login credentials like username and password of the user in Active Directory using C#? You can do it using the classes provided in the Directory Services namespace. You need to include the assemblies “System.DirectoryServices” and “System.DirectoryServices.AccountManagement” in your solution. How to validate a user in Active Directory using C#? Below is a sample code snippet demonstrating…
How to reverse a string in C#?
Below is a sample code snippet demonstrating on how to reverse a string in C#? How to reverse a string in C#?
C# and LINQ – 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 LINQ in C#. The where keyword in C# is used to filter the elements from a collection based on the specified criteria. Ensure that you import the System.Linq namespace to your C# code. How to find all the elements of an integer array…
How to Launch Map Application in Windows Phone 8 using C#?
Below is a sample code snippet that demonstrates how to launch the Maps Application in Windows Phone 8 programmatically using C#. How to Launch Map Application in Windows Phone 8 using C#?
Example of Enumeration in C#
Below is a sample code snippet that demonstrates how to declare , define and access the Enumeration in C#. Example of Enumeration in C#
How to remove non alphanumeric characters (special characters) from a string in C# ?
One of the simplest way to remove non alphanumeric characters from a string is using the regular expressions . Below is a sample code snippet that demonstrates how to delete the non alphanumeric characters from a string in C#. How to remove non alphanumeric characters (special characters) from a string in C# ?