Samual Sam has Published 2492 Articles

C# program to add two matrices

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:56:22

6K+ Views

Firstly, set three arrays.int[, ] arr1 = new int[20, 20]; int[, ] arr2 = new int[20, 20]; int[, ] arr3 = new int[20, 20];Now users will enter values in both the matrices. We have to set the row and size columns as n=3, since we want a square matrix of ... Read More

C# Object Creation of Inherited Class

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:53:34

1K+ Views

A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.The derived class inherits the base class member variables and member methods. Therefore, the super class object should be created before the subclass is ... Read More

C# program to remove n-th character from a string

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:43:17

653 Views

To remove a character, use the remove() method and set the index from where you want to delete the character.Firstly, set the string.string str1 = "Amit"; Console.WriteLine("Original String: "+str1);To delete a character at position 4.StringBuilder strBuilder = new StringBuilder(str1); strBuilder.Remove(3, 1);You can try to run the following code to remove ... Read More

Difference between namespace in C# and packages in Java

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:41:31

3K+ Views

Packages in JavaPackages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in ... Read More

Delegation vs Inheritance in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:37:53

504 Views

Delegates in C#A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.To declare a delegate.delegate Delegation has run-time flexibility i.e. you can easily change it at runtime. The instance you create in Delegation is of a known ... Read More

What is the scope of an internal variable of a class in C#?

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:35:44

755 Views

Internal variable is set using the internal access specifier.internal double length; internal double width;Any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.Example Live Demousing System; namespace RectangleApplication {    class Rectangle {       //member ... Read More

Division Operator in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:32:12

6K+ Views

Division operator is used in C# to divide numerator by denominator, for example 9/ 3The division operator comes under Arithmetic Operators in C#. Let us see a complete example to learn how to implement Arithmetic operators in C#, wherein we will see how to work with division operator.result = num1 ... Read More

Comparing dates using C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:29:16

240 Views

To compare dates in C#, you need to first set two dates to be compared using the DateTime object. We will use the DateTime class in C#.Date 1DateTime date1 = new DateTime(2018, 07, 20); Console.WriteLine("Date 1 : {0}", date1);Date 2DateTime date2 = new DateTime(2018, 07, 25); Console.WriteLine("Date 2 : {0}", ... Read More

Default constructor in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:25:13

240 Views

A Constructor in C# is invoked automatically when an object gets created. The constructor has the same name as that of the class, for example −public class Department {    public Department () {       Console.WriteLine("Default Constructor! ");    } }The following is the code that shows the ... Read More

C# Program to get the type of the specified Enumeration

Samual Sam

Samual Sam

Updated on 23-Jun-2020 09:18:47

109 Views

Use the GetType() method to get the type of the enumeration.The enumeration.Enum[] values = { ConsoleColor.Blue, DayOfWeek.Sunday};Now to get the type, use the GetType() method.Type enumType = val.GetType();The following is an example that displays the type.Example Live Demousing System; public class Demo {    public static void Main() {     ... Read More

Advertisements