Method Overloading in C#

karthikeya Boyini
Updated on 20-Jun-2020 15:38:14

2K+ Views

Two or more than two methods having the same name but different parameters is what we call method overloading in C#.Method overloading in C# can be performed by changing the number of arguments and the data type of the arguments.Let’s say you have a function that prints multiplication of numbers, then our overloaded methods will have the same name but different number of arguments −public static int mulDisplay(int one, int two) { } public static int mulDisplay(int one, int two, int three) { } public static int mulDisplay(int one, int two, int three, int four) { }The following is an ... Read More

Write in Order with For Loop or While Loop

Arnab Chakraborty
Updated on 20-Jun-2020 15:34:17

269 Views

Example#include #include void main() {    int i,j,a=0,b=1,n;    clrscr();    printf("****************OUTPUT*****************");    printf("enter the value of n : ");    scanf("%d",&n);    printf(" the required order is: " );    for(i=1;i

Main Parts of a C Hash Program

Samual Sam
Updated on 20-Jun-2020 15:32:32

2K+ Views

The main parts of a C# program includes −Namespace declarationA classClass methodsClass attributesA Main methodStatements and ExpressionsCommentsThe following is an example showing how to create a C# program −Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          Console.WriteLine("Our first program in C#!");          Console.ReadKey();       }    } }OutputOur first program in C#!Here are the parts of the C# program we saw above −using System; - the using keyword is used to include the System namespace in the program. A program ... Read More

Methods and Properties of the Thread Class in C#

George John
Updated on 20-Jun-2020 15:31:04

529 Views

Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems.The following are some of the properties of the Thread class −Sr.No.Property & Description1CurrentContextGets the current context in which the thread is executing.2CurrentCultureGets or sets the culture for the current thread.3CurrentPrincipleGets or sets the thread's current principal (for role-based security).4CurrentThreadGets the currently running thread.5CurrentUICultureGets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.6ExecutionContextGets an ExecutionContext object that contains information about the various contexts of the current thread.7IsAliveGets a value indicating the execution status ... Read More

Item Property of BitArray Class in C#

karthikeya Boyini
Updated on 20-Jun-2020 15:30:41

116 Views

The Item property of the BitArray class gets or sets the value of the bit at a specific position in the BitArray.Use the keyword to define the indexers instead of implementing the Item property. To access an element, use the mycollection[index].The following is the implementation of BitArray class Item property −Example Live Demousing System; using System.Collections; class Demo {    static void Main() {       bool[] arr = new bool[5];       arr[0] = true;       arr[1] = true;       arr[2] = false;       arr[3] = false;       BitArray ... Read More

Use Chash BinaryWriter Class in C#

Samual Sam
Updated on 20-Jun-2020 15:29:26

192 Views

If you want to write binary information into the stream, then use the BinaryWriter class in C#. You can find it under the System.IO namespace.The following is the implementation of the BinaryWriter class −static void WriteMe() {    using (BinaryWriter w = new BinaryWriter(File.Open("C:\abc.txt", FileMode.Create))) {       w.Write(37.8);       w.Write("test”);    } } static void ReadMe() {    using (BinaryReader r = new BinaryReader(File.Open("C:\abc.txt", FileMode.Open))) {       Console.WriteLine("Value : " + r.ReadDouble());       Console.WriteLine("Value : " + r.ReadString());    } }Above, theBinaryWriter class opens a file and writes content into it ... Read More

Use of Chash BinaryReader Class

Arjun Thakur
Updated on 20-Jun-2020 15:28:41

199 Views

Use the BinaryReader class if you want to read binary information from the stream.The BinaryReader class is in System.IO namespace.The following is an example showing using the BinaryReader class to read from a file −static void WriteMe() {    using (BinaryWriter w = new BinaryWriter(File.Open("C:\abc.txt", FileMode.Create))) {       w.Write(25.9);       w.Write("DEMO DATA");    } } static void ReadMe() {    using (BinaryReader r = new BinaryReader(File.Open("C:\abc.txt", FileMode.Open))) {       Console.WriteLine("Value : " + r.ReadDouble());       Console.WriteLine("Value : " + r.ReadString());    } }The above method is called in the Main() method ... Read More

Different Access Specifiers in C# .NET

Chandu yadav
Updated on 20-Jun-2020 15:27:58

5K+ Views

The following are the access specifiers supported by C#.NET −Public Access SpecifierIt allows a class to expose its member variables and member functions to other functions and objects.Private Access SpecifierPrivate access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members.Protected Access SpecifierProtected access specifier allows a child class to access the member variables and member functions of its base class.Internal Access SpecifierInternal access specifier allows a class to expose its member variables and member functions to other functions and objects in ... Read More

Use HashFileStream Class in Java

Samual Sam
Updated on 20-Jun-2020 15:27:34

336 Views

A stream for file operations such as read and write is provided by the FileStream class.Create an object like thisFileStream fstream = new FileStream("d:ew.txt", FileMode.OpenOrCreate);Above we have used FileMode.OpenOrCreate so that the file or opened or created if it does not already exist.The following is n example showing how to use the FileStream class in C# −using System; using System.IO; public class Demo {    public static void Main(string[] args) {       FileStream fstream = new FileStream("d:ew.txt", FileMode.OpenOrCreate);       // write into the file       fstream.WriteByte(90);       // close the file       fstream.Close();    } }

Calculate Size of Folder Using Chash

karthikeya Boyini
Updated on 20-Jun-2020 15:26:47

4K+ Views

To calculate the size of a folder in C#, use the Directory.EnumerateFiles Method and get the files.To get the sub- directories, use the EnumerateDirectories method. Our folder is set using DirectoryInfo class −DirectoryInfo info = new DirectoryInfo(@"D:/new");Now find the size −long totalSize = info.EnumerateFiles().Sum(file => file.Length); For the directories, use −info.EnumerateDirectories()Other manipulations you can perform on Directories in C# are:MethodDescriptionCreateDirectory(String)Creates all directories and subdirectories in the specified path unless they already exist.CreateDirectory (String, DirectorySecurity)Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.Delete(String)Deletes an empty directory from a specified path.Delete(String, Boolean)Deletes the specified ... Read More

Advertisements