karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 50 of 143

How to convert Lower case to Upper Case using C#?

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 3K+ Views

To convert Lower case to Upper case, use the ToUpper() method in C#.Let’s say your string is −str = "david";To convert the above lowercase string in uppercase, use the ToUpper() method −Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper());The following is the code in C# to convert character case −Exampleusing System; using System.Collections.Generic; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {          string str;          str = "david";          Console.WriteLine("LowerCase : {0}", str);          // convert to uppercase          Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper());          Console.ReadLine();       }    } }

Read More

What is a sealed class in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 861 Views

Sealed class in C# with the sealed keyword cannot be inherited. In the same way, the sealed keyword can be added to the method.When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.Let us see an example of sealed class in C# −Exampleusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class Program {       static void Main(string[] args) {          Result ob = new ...

Read More

Mathematical Functions in C#

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 2K+ Views

The System.Math class in C# provides methods are properties to perform mathematical operations, trigonometric, logarithmic calculations, etc.Some of its methods include −Sr.NoMethod & Description1Abs(Decimal)Returns the absolute value of a Decimal number.2Abs(Double)Returns the absolute value of a double-precision floating-point number.3Abs(Int16)Returns the absolute value of a 16-bit signed integer.4Abs(Int32)Returns the absolute value of a 32-bit signed integer.5Abs(Int64)Returns the absolute value of a 64-bit signed integer.6Abs(SByte)Returns the absolute value of an 8-bit signed integer.7Abs(Single)Returns the absolute value of a single-precision floating-point number.8Acos(Double)Returns the angle whose cosine is the specified number.9Asin(Double)Returns the angle whose sine is the specified number.10Atan(Double)Returns the angle whose tangent is ...

Read More

What is the octal equivalent of a decimal number in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 245 Views

To get the octal equivalent of a decimal in C# −Firstly, for the decimal value use a while loop and store the remainder in the array set for octal. Here we found the mod 8 of them in the array.After that, divide the number by 8 −while (dec != 0) {    oct[i] = dec % 8;    dec = dec / 8;    i++; }Let us see the complete code. Here, our decimal number is 12 −Exampleusing System; namespace Demo {    class Program {       static void Main(string[] args) {       ...

Read More

What are the escape sequences supported by C#?

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 217 Views

The following is an example showing how to display some of the escape characters in C# −Exampleusing System; using System.Collections.Generic; class Demo {    static void Main() {       Console.WriteLine("Warning!" + '\u0007');       Console.WriteLine("Test \t Demo Text");       Console.WriteLine("This is it!This is on the next line!");    } }For the complete list of escape sequences in C# −Escape characterDescriptionPattern\aMatches a bell character, \u0007.\a\bIn a character class, matches a backspace, \u0008.[\b]{3, }\tMatches a tab, \u0009.(\w+)\t\rMatches a carriage return, \u000D. (\r is not equivalent to the newline character, .)\r(\w+)\vMatches a vertical tab, ...

Read More

What are punctuators in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 21-Jun-2020 685 Views

Punctuators are used in C# as special symbols to a group or divide the code. It includes −] () {}, ; * = #For example, = gets included in a class or even while declaring a variable. Statement ends with a semi-colon −int a = 10;In a class, the braces are used −class Demo { }While declaring a dictionary −var d = new Dictionary(5);It is also used while declaring and initializing a list −List myList = new List() {    "mammals",    "reptiles",    "amphibians" };

Read More

Thread Pools in C#

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 4K+ Views

Thread pool in C# is a collection of threads. It is used to perform tasks in the background. When a thread completes a task, it is sent to the queue wherein all the waiting threads are present. This is done so that it can be reused.Let us see how to create a thread pool.Firstly, use the following namespace −using System.Threading;Now, call the threadpool class, using the threadpool object. Call the method QueueUserWorkItem −ThreadPool.QueueUserWorkItem(new WaitCallback(Run)); Iterate this in a loop and compare it with a normal Thread object.

Read More

Try/catch/finally/throw keywords in C#

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 2K+ Views

Exception handling is based on the following keywords and its usage −try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed ...

Read More

What is the base class for all data types in C#.NET?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 2K+ Views

Object is the base class for all data types in C#. The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System.Object class.When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing.The following is an example showing the usage of object data types −using System; using System.IO; namespace Demo {    class objectClass {       public int x = 56;   ...

Read More

How to use NameValueCollection class in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Jun-2020 737 Views

The NameValueCollection sets more than one value for a single key. Now let us see how to use them in our C# program.Set the collection −static NameValueCollection GetCollection() {    NameValueCollection myCollection = new NameValueCollection();    myCollection.Add("Tim", "One");    myCollection.Add("John", "Two");    myCollection.Add("Jamie", "Three");    return myCollection; }Now with the GetCollection() method use the “AllKeys” method property to display all the keys −NameValueCollection myCollection = GetCollection(); foreach (string key in myCollection.AllKeys) {    Console.WriteLine(key); }

Read More
Showing 491–500 of 1,421 articles
« Prev 1 48 49 50 51 52 143 Next »
Advertisements