Skip to main content

Posts

Showing posts from January, 2016

SQL Server "Primary Key", "Unique Key" and "Foreign Key" [Database]

The PRIMARY KEY and UNIQUE KEY both are similar and it used to apply the uniqueness of the columns and   also used for uniquely identify each row in database tables. The major difference between Primary key, Unique key and Foreign Key as given below.             Primary Key 1.        A primary key cannot accept null values.            2.        A primary key must be unique. 3.        By default,  primary key create only one clustered index in the database . 4.        Each table can have one and only one primary key. 5.        Each table can have one and only one clustered index. 6.        Primary key can be made foreign key into another table. 7.   ...

Count character occurrence of a string using dictionary KeyValuePair C#?

Hello everyone, I am going to share the code sample for find and count the characters of a string using dictionary key value pair. The example as given below. /// <summary> /// Count character occurrence of a string using dictionary KeyValuePair C#? /// </summary> public class CountCharsOccurrence {     static void Main( string [] a)     {         Dictionary < char , int > dicList = new Dictionary < char , int >();         Console .WriteLine( "Enter charater sting" );         foreach ( var chr in Console .ReadLine())         {             int count = 0;             if (dicList.ContainsKey(chr))        ...

Find the most occurrence of a character in string C#?

Hello everyone, I am going to share the code sample for find the most occurrence of a character in string using ASP.Net C# . The example in detail with output as given below. public class CountMostOccurrenceCharacters { static void Main( string [] ss) {     Dictionary < char , int > dicList = new Dictionary < char , int >();     int last = 0;     Console .WriteLine( "Enter the charactor string" );     foreach ( char chr  in Console .ReadLine())     {         int  count;         dicList.TryGetValue( chr  , out  count);          count ++;         if ( count  > last)         {             last =  count ; ...

Reverse string in with and without using reverse function in C#

Hello everyone, I'm sharing the code sample for Reverse strings and numbers with and without using the  reverse function .  The example in detail is given below. Example 1, Using for loop /// REVERSE STRIG WITH USING C# FUNCTIONS public class ReverseStrigs {      static void Main( string [] a)     {     Console .WriteLine( "Enter string for Reverse" );         string str = Console .ReadLine();         Console .WriteLine( Reverse (str));         Console .ReadLine();     }     public static string Reverse( string str)     {         return new string (str.Reverse().ToArray());     } } /// REVERSE STRIG WITHOUT USING C# FUNCTIONS. public class ReverseStrigs {   ...