The easiest way of getting unique items from list is LINQ’s Distinct() method. In this article you’ll see how to use it with both built-in types (like collection of integers) and custom types (like collection of complex type objects). Get unique values from collection of integers Let’s start with creating example list of items where … Continue reading C# – How to get unique items from list
Category: How To
C# – How to split a string
String can be split into collection of substrings based on a defined character (separator) using Split() function. Split is part of String class which exists in the System namespace. Split function is overloaded and has various forms which allow to: pass separator as a single character, array of characters, single string or array of strings; … Continue reading C# – How to split a string
C# – How to convert string to int
There are three easiest ways which allow you to convert string data type to int: Parse method TryParse method Convert class In the following article I’ll explain each one and show the example of its usage. Parse method Basic form of Parse method receives string as an input parameter and returns converted value as an … Continue reading C# – How to convert string to int
C# – How to check if string contains only digits
There are plenty of methods to achieve this but even though it’s simple task you need to specify requirements like: are white spaces allowed? how to treat empty string? what’s the maximum length of the string? In this article I want to describe 3 different ideas how to solve this problem. Custom function Let’s say … Continue reading C# – How to check if string contains only digits
C# – How to generate Guid
.NET Framework provides built-in Guid structure which allows to generate unique identifier. The usage is very simple and requires to call NewGuid function on Guid structure. Guid guid = Guid.NewGuid(); 1 Guid guid = Guid.NewGuid(); Returned object type is Guid however we can easily convert it to string. var guidString = guid.ToString(); 1 var guidString = … Continue reading C# – How to generate Guid
.NET Framework upgrade
How to upgrade .NET Framework? First of all you need to install desired framework version on both development and client machines. Development machine is an environment where you code and build your project. It requires .NET Framework Developer Pack. Client machine is an environment where your application is used. It requires lighter package .NET Framework … Continue reading .NET Framework upgrade