Reusability in C#: C# lets you reuse code in two major ways: Inheritance Generics Let’s look at each: 1. Inheritance: Inheritance is an object-oriented concept. You write a base class and then extend it to create more specific classes . Example: class Animal { public void Eat() { Console.WriteLine("Eating..."); } } class Dog : Animal { public void Bark() { Console.WriteLine("Barking..."); } } // Reusing code via inheritance Dog d = new Dog(); d.Eat(); // From Animal d.Bark(); // From Dog ✅ Pros : Useful when classes share common behavior. ❌ Cons : Less flexible when working with types (like int , string , etc.) 2. Generics: Gen...
datatable compute sum in c# | datatable compute() function Hi Readers, Today I am going to explain you the use of compute() function of Data table using C#.NET . Let's begin.. datatable column sum in c# datatable compute sum in c# | datatable compute() function Let's say that we have the following rows filled in the Data table with the columns ID,NAME,AGE and SALARY as shown in snapshot below:- employees detail in datatable In order to calculate the figures like total of salary, average of salary, maximum salary and minimum salary, we can use the compute() function of the Data table. The compute() function loops through each value of the column's cell and then perform the calculation. For the above data table's salary column, lets find the total, average, maximum and minimum of salary one by one using compute() function:- datatable compute sum in c# | datatable compute() function Calculate the total of sala...