Found 27104 Articles for Server Side Programming

Assertions in C#

karthikeya Boyini
Updated on 19-Jun-2020 08:14:00

2K+ Views

Assert statements are an effective way to catch program logic errors at runtime. It has two arguments −A boolean expression for a true condition, andWhat to display in case of false.Assertions are useful in large and complex programs to quickly flush out errors that generally arise when the code is modified. Avoid using any function call inside the assert method.You need to be sure that whatever code you add inside an Assert should not change the output if it is removed. This is when you implement Debug. Assert in your program.To implement it, you can use a temporary variable −int ... Read More

ArrayList in C#

Samual Sam
Updated on 19-Jun-2020 07:49:26

496 Views

A resizable implementation of the List interface is called ArrayList. It is a non-generic type of collection in C# that dynamically resizes.Let us see how to initialize ArrayList in C# −ArrayList arr= new ArrayList();Add an element like the below-given code snippet −ArrayList arr1 = new ArrayList(); arr1.Add(120); arr1.Add(160);Let us see the complete example to implement ArrayList in C# −ExampleLive Demousing System; using System.Collections; public class MyClass {    public static void Main() {       ArrayList arr1 = new ArrayList();       arr1.Add(120);       arr1.Add(160);       ArrayList arr2 = new ArrayList();   ... Read More

Beginning C# programming with Hello World

karthikeya Boyini
Updated on 19-Jun-2020 07:51:01

354 Views

The following is a simple “Hello World” program in C# programming −ExampleLive Demousing System; namespace MyHelloWorldApplication {    class MyDemoClass {       static void Main(string[] args) {          // display text          Console.WriteLine("Hello World");          // display another text          Console.WriteLine("Welcome!");          Console.ReadKey();       }    } }OutputHello World Welcome!Let us see now what all it includes −using System − the using keyword is used to include the System namespace in the program.namespace declaration − A namespace is a collection of classes. The ... Read More

array-of- arrays double [][] in C#?

Samual Sam
Updated on 19-Jun-2020 07:31:53

716 Views

Arrays of arrays in C# are known as Jagged Arrays. To declare jagged arrays, use the double [ ][ ].Let us now declare them −int [][] marks;Now, let us initialize it, wherein marks are arrays of 5 integers −int[][] marks = new int[][]{new int[]{ 90, 95 }, new int[]{ 89, 94 }, new int[]{ 78, 87 }, new int[]{ 76, 68 }, new int[]{ 98, 91 } };ExampleLet us now see the complete example of jagged arrays in C# and learn how to implement it −Live Demousing System; namespace MyApplication {    class MyDemoClass {       static void ... Read More

Access Modifiers in C#

karthikeya Boyini
Updated on 19-Jun-2020 07:32:31

430 Views

Access Modifiers specifies the scope of variable and functions in C#. The following are the access modifiers used provided by C#:PublicThe public modifier sets no restriction on the access of members.ProtectedAccess limited to the derived class or class definition.InternalThe Internal access modifier access within the program that has its declaration.Protected internalIt has both the access specifiers provided by protected and internal access modifiers.PrivateLimited only inside the class in which it is declared. The members specified as private cannot be accessed outside the class.ExampleLet us see an example of protected access modifier, accessing the protected members −Live Demousing System; namespace MySpecifiers ... Read More

Asynchronous programming in C# using Async and Await keyword

Samual Sam
Updated on 19-Jun-2020 07:33:17

2K+ Views

Asynchronous programming in C# is an efficient approach towards activities blocked or access is delayed. If an activity is blocked like this in a synchronous process, then the complete application waits and it takes more time. The application stops responding. Using the asynchronous approach, the applications continue with other tasks as well.The async and await keywords in C# are used in async programming. Using them, you can work with .NET Framework resources, .NET Core, etc.  Asynchronous methods defined using the async keyword are called async methods.An application with a GUI, check the content of the queue and if an unprocessed ... Read More

Abstract Classes in C#

karthikeya Boyini
Updated on 19-Jun-2020 07:34:12

2K+ Views

An abstract class in C# includes abstract and non-abstract methods. A class is declared abstract to be an abstract class. You cannot instantiate an abstract class.Let us see an example, wherein we have an abstract class Vehicle and abstract method display()−public abstract class Vehicle {    public abstract void display(); } The abstract class has derived classes: Bus, Car, and  Motorcycle. The following is an implementation of the Bus derived class −public class Bus : Vehicle {    public override void display() {       Console.WriteLine("Bus");    } } ExampleLet us see the complete example of abstract classes in C# −Live ... Read More

A Deque Class in C#

Samual Sam
Updated on 19-Jun-2020 07:35:29

1K+ Views

The Deque class uses a doubly-linked list to implement its collection of elements.  The doubly-linked lists should have two nodes i.e. front and back nodes. This helps in adding elements on the front and back of the Deque.With the Deque class, you have the ability to add and remove elements from both the sides. This is why Deque is said to be a double-ended queue.The Deque class has the following methods in the Queue class −ClearClears the collection of all of its elementsContainsWhether or not an object is in the collectionToArrayUse the ToArray() method to copy all of the elements ... Read More

‘this’ keyword in C#

karthikeya Boyini
Updated on 19-Jun-2020 07:38:18

9K+ Views

The “this” keyword in C# is used to refer to the current instance of the class. It is also used to differentiate between the method parameters and class fields if they both have the same name.Another usage of “this” keyword is to call another constructor from a constructor in the same class.Here, for an example, we are showing a record of Students i.e: id, Name, Age, and Subject. To refer to the fields of the current class, we have used the “this” keyword in C# −public Student(int id, String name, int age, String subject) {    this.id = id;   ... Read More

How can I remove the same element in the list by Python

Vikram Chiluka
Updated on 27-Oct-2022 12:12:50

2K+ Views

In this article, we will show you how to remove the same element in the list in python. In simple words removing common elements from both lists. Below are the various methods to accomplish this task − Using remove() function Using List Comprehension Using Set difference operator Using Set difference() function Assume we have taken two lists containing some elements. We will now remove the same or common elements from both lists. Using remove() function Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Create a variable to store the inputList_1. ... Read More

Advertisements