Ankith Reddy has Published 1070 Articles

String Template Class in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 09:29:37

352 Views

StringTemplate class is used to parse the format string, so that it is compatible with String.Format. The StringTemplate class comes under the NString library that has extension methods. These methods makes string manipulations easy to use like.IsNullOrEmpty() IsNullOrWhiteSpace() Join() Truncate() Left() Right() Capitalize()StringTemplate.Format is better than String.Format since it is ... Read More

How to convert a list to string in C#?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 09:25:18

2K+ Views

Declare a list.List < string > l = new List < string > ();Now, add elements to the list.// elements l.Add("Accessories"); l.Add("Footwear"); l.Add("Watches");Now convert it into a string.string str = string.Join(" ", l.ToArray());Let us see the final code to convert a list to string in C# −Exampleusing System; using System.Collections.Generic; ... Read More

How to check if an item exists in a C# array?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 09:11:45

4K+ Views

Use the Equals method to check if an item exists in a C# array.Set string and substring −string subStr = "pqrs"; string[] str = {    "abcd",    "ijkl",    "pqrs",    "wxyz" };Now check whether the substring is part of the string or not using the Equals method.if (item.Equals(subStr)) ... Read More

How to print one dimensional array in reverse order?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 09:08:24

369 Views

Firstly, declare and initialize one dimensional array.int[] arr = { 35, 12, 66, 90, 34, 2, 64 };Now, use the following to reverse −Array.Reverse(arr);The following is the complete code to reverse a one-dimensional array;Example Live Demousing System; class Demo {    static void Main() {       int[] arr ... Read More

How to find a number in a string in C#?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 09:05:10

269 Views

To find a number in a string, use Regular Expressions.We have set the Regex pattern to get number from a string.Regex r = new Regex(@"\d+");Now, use Match class in C# to set the string.Match m = r.Match("Welcome! We are open 365 days in a year!");Use the Success property now to ... Read More

Lifecycle and States of a Thread in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 08:57:53

347 Views

Threads are lightweight processes. Each thread defines a unique flow of control. The life cycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution.Here are the various states in the life cycle of a thread −The Unstarted ... Read More

Quickly convert Decimal to other bases in C#

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 08:37:39

476 Views

To quickly convert decimal to other bases, use Stacks. Let us see an example.Firstly, I have set the variable “baseNum” as 2int baseNum = 2;In the same way, if you want another base, then −// base 8 int baseNum = 8; // base 10 int baseNum = 10;After getting ... Read More

What is the use of comparison operators with MySQL subquery?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 08:25:03

115 Views

The subquery can return at most one value. The value can be the result of an arithmetic expression or a column function. MySQL then compares the value that results from the subquery with the value on the other side of the comparison operator. MySQL subquery can be used before or ... Read More

How to perform Division of Exponents of Same Base using C#?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 08:23:13

145 Views

Firstly, set the base −double n = 10;Now set the two exponents for division −double e1 = 10; double e2 = 8;Let us see the complete code to get the result of division of exponents of the same base.Example Live Demousing System; class Demo {    static void Main() { ... Read More

MySQL BIT_LENGTH() function is multi-byte safe or not?

Ankith Reddy

Ankith Reddy

Updated on 22-Jun-2020 07:45:29

85 Views

Just like LENGTH() function, MySQL BIT_LENGTH() function is not a multi-byte safe function. As we know that the difference of the result between multi-byte safe functions, like CHAR_LENGTH() or CHARACTER_LENGTH(), and BIT_LENGTH() function especially relevant for Unicode, in which most of the characters are encoded in two bytes or relevant ... Read More

Advertisements