06/06/2015 by Nitesh

How To Count Occurrences of a String Within Another String in C#

Friends, In programming while performing some business logic validations, many times we need to find a text within another text. In this post, we will see how can we count occurrences of a string within another string in C#. static void CountOccurenceswWithinString() {    string test = “Hello, how are youyou you you you, you…

Continue Reading »

05/06/2015 by Nitesh

How To Get Public IP Address Using C#

Friends, In this post, we will see how can we get public IP Address of a computer using C#. We will make use of WebRequest class to make a call to the server that returns the IP address of the machine that made the request. Here’s the code snippet that does this – static string…

Continue Reading »

04/06/2015 by Nitesh

How To Sort A Dictionary Object by Values in C#

Friends, Microsoft .Net provides us with classes like SortedDictionary that allows the elements of a Dictionary class to be sorted by Keys. However, in some scenarios we want the Dictionary elements to be sorted by the values present in each element. Today, in this post we will see how can we sort a Dictionary Object…

Continue Reading »

02/06/2015 by Nitesh

How To Create a TextBox Accepting Only Numbers in Windows Forms

Friends, Many times we need to have a textbox on our windows forms where we need to accept only numbers from the end users. .Net does provide us a NumericUpDown control but it is not always handy. In this post, we will see how we can create a TextBox accepting only numbers in Windows Forms…

Continue Reading »

01/06/2015 by Nitesh

How To Calculate Age in C#

Friends, Another post that is used in almost every application built where one need to calculate the age of a person using C# when his/her Date Of Birth is given. This post will explain how can we calculate age in C# when the user enters his/her Date Of Birth.      static void CalculateAndPrintAge(DateTime birthday)     …

Continue Reading »

1 2 3 4 10