karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 16 of 143

C# Queryable Take() Method

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

The Take() method in C# is a LINQ extension method that returns a specified number of contiguous elements from the start of a sequence. It's commonly used with IQueryable collections to limit the number of results returned from a query. Syntax Following is the syntax for the Take() method − public static IQueryable Take( this IQueryable source, int count ) Parameters source − The IQueryable to return elements from. count − The number of elements to return. Return Value ...

Read More

C# Program to Convert Character case

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 616 Views

Converting character case in C# is a common string manipulation task. The string class provides built-in methods ToLower() and ToUpper() to convert strings to lowercase and uppercase respectively. Syntax Following is the syntax for converting string case − string.ToLower() // Converts to lowercase string.ToUpper() // Converts to uppercase Both methods return a new string with the case converted and do not modify the original string. Using ToLower() Method The ToLower() method converts all uppercase characters in a string to lowercase − using System; ...

Read More

Get the creation time of a file in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

To get the creation time of a file in C#, you can use the CreationTime property of the FileInfo class or the static methods from the File class. This allows you to retrieve when a file was originally created on the file system. Syntax Using the FileInfo class − FileInfo fileInfo = new FileInfo("filename.txt"); DateTime creationTime = fileInfo.CreationTime; Using the static File class − DateTime creationTime = File.GetCreationTime("filename.txt"); Using FileInfo Class The FileInfo class provides an object-oriented approach to work with file information. Create a FileInfo object and access ...

Read More

C# Program to Convert Decimal to Binary

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 1K+ Views

Converting a decimal number to binary involves repeatedly dividing the decimal number by 2 and collecting the remainders. In C#, this can be accomplished using manual division or built-in methods like Convert.ToString(). The manual approach uses the division by 2 method where we divide the decimal number by 2, store the remainder, and continue until the quotient becomes 0. The binary representation is formed by reading the remainders in reverse order. Using Manual Division Method This method involves dividing the decimal number by 2 repeatedly and collecting remainders − Decimal to Binary ...

Read More

What are punctuators in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 699 Views

Punctuators are special symbols in C# that serve as delimiters to structure, group, and organize code. They are essential for proper syntax and help the compiler understand where statements begin and end, how to group code blocks, and how to separate elements. Common Punctuators in C# The most frequently used punctuators in C# include − { } // Braces - code blocks ( ) // Parentheses - method calls, grouping [ ] // Brackets - arrays, indexers ; // Semicolon - statement terminator , ...

Read More

Literal number suffixes in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 532 Views

Literal number suffixes in C# are used to explicitly specify the data type of numeric literals. Without suffixes, the compiler infers the type based on the value, but suffixes ensure the literal is treated as a specific numeric type. These suffixes are particularly useful when working with method overloads, preventing ambiguous type conversions, and ensuring the correct data type is used for calculations. Syntax Following is the syntax for using literal number suffixes − dataType variable = numericValue + suffix; The suffix can be either uppercase or lowercase, but uppercase is recommended for ...

Read More

C# Program to order array elements

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 173 Views

C# provides several methods to order array elements. The OrderBy() method sorts elements in ascending order, while ThenBy() is used for secondary sorting criteria when multiple elements have the same primary sort value. Syntax Following is the syntax for ordering array elements using LINQ methods − // Primary ordering IEnumerable result = array.OrderBy(item => item.Property); // Primary and secondary ordering IEnumerable result = array.OrderBy(item => item.Property1) ...

Read More

C# Program to convert first character uppercase in a sentence

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 545 Views

Converting the first character of each word to uppercase in a sentence is a common text formatting task in C#. This process involves identifying word boundaries and converting the first lowercase letter of each word to its uppercase equivalent. Syntax Following is the basic approach to convert characters from lowercase to uppercase − char uppercaseChar = (char)(lowercaseChar - 'a' + 'A'); To check if a character is a lowercase letter − if (ch >= 'a' && ch = 'a' && val[i] = 'A' && val[i] word.Length > 0 ? ...

Read More

How to call a method of a class in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

To call a method of a class in C#, you need to create an instance of the class first, then use the dot notation to access its methods. The general syntax is objectName.MethodName(parameters). Syntax Following is the syntax for calling an instance method − ClassName objectName = new ClassName(); returnType result = objectName.MethodName(parameters); For static methods, you call them directly on the class without creating an instance − returnType result = ClassName.StaticMethodName(parameters); Using Instance Methods Instance methods require an object of the class to be called. Here's how you ...

Read More

Random Numbers in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 22K+ Views

The Random class in C# is used to generate pseudo-random numbers. It provides various methods to generate random integers, doubles, and bytes within specified ranges. Syntax Following is the syntax for creating a Random object and generating random numbers − Random rd = new Random(); int randomNumber = rd.Next(minValue, maxValue); Following are the commonly used methods of the Random class − rd.Next() // Random int from 0 to int.MaxValue rd.Next(maxValue) ...

Read More
Showing 151–160 of 1,421 articles
« Prev 1 14 15 16 17 18 143 Next »
Advertisements