Skip to main content

Posts

Showing posts from May, 2020

The contains method of String In C#

The contains method of String In C# The string  Contains   method  is used to check whether the specified substring exists in the given  string  or not and it will return a boolean value.   In case, if a substring exists in a  string , then the  contains  method will return  true  otherwise it will return  false .   Contains Method Syntax The following is the syntax for defining a  Contains   method  to check whether the substring exists in a given  string  or not.   public bool Contains( string value)   From the syntax above, the  Contains   method  will check whether the substring value exists or not and it will return a boolean value.   Contains Method Example in C# Following is the example of using  Contains()   method  to check whether the given value (substring) occurs within the  string  or not.   using...

Why 2020 is the Year of Cockroaches

We hope your week has been good. Everyone talks about how 2020 is turning out to be a year nobody expected. A year where our dreams, plans and goals have been put in disarray. But you know what? Let's talk about why this is the year for some kind of people. About cockroaches. They are resilient. It is said that they are one of the few creatures who could survive a nuclear blast! They can hide so well when there is danger. They learn to do so many things to adapt including flying (which they didn't use to do).  So how do you survive and thrive this year in the midst of all the negativity? 1. Adapt:  Adapting is a skill. Companies have had to adapt to new realities. As an individual you should also. Seek alternatives to original plans affected by Covid-19. 2. Look Critically at the Market to see Gaps : If you are at the phase where you are thinking of what next to do - observe, research and study the environment around you. Note all the ideas that come to your head. Find that ne...

The Compare method of string in C# Explained

The Compare method of string in C# The string  Compare   method  is used to compare two specified  strings  and return an integer value that indicates their relative position in the sort order.   The return integer value indicates the lexical relationship between the two specified  strings . The table below lists the values that will be returned by the  Compare   method  after comparing the two specified  strings .   Condition Return Value strA equals strB (strA == strB) 0 strA greater than strB (strA > strB) 1 strA less than strB (strA < strB) -1   Example Str1 = “Musa” Str2 = “Sule” Using the compare method as String.Compare(Str1,Str2) returns (-1) since “Sule” is lexically greater than “Musa”   C# String Compare Method Syntax The syntax below shows the definition of a  Compare   method...

Split Method of String Class in C# Explained

Split Method of String Class in C# In C#, Split() is a  string class  method. The Split() method returns an array of strings generated by splitting of original string separated by the delimiters passed as a parameter in Split() method. The delimiters can be a character or an array of characters or an array of strings. Or you can also say that it returns a string array which contains the substrings in the current instance that are delimited by elements of a specified string or Unicode character array. Split Method Syntax The following is the syntax of defining a split  method  in C#.   //split syntax in C#   public string [] Split( char [] separator)   From the above syntax, we are using a character array ( char[] ) as argument to define delimiters to split the given string into  substrings  and return it as a string  array .   Example of Split Method in C# The code snippets below is the example of splitting t...