Server Side Programming Articles - Page 1672 of 2650

How to use order by, group by in c#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 09:07:34

3K+ Views

Order by is used to sort the arrays in the ascending or in the descending orderGroupBy operator belong to Grouping Operators category. This operator takes a flat sequence of items, organize that sequence into groups (IGrouping) based on a specific key and return groups of sequenceExampleclass ElectronicGoods {    public int Id { get; set; }    public string Name { get; set; }    public string Category { get; set; }    public static List GetElectronicItems() {       return new List() {          new ElectronicGoods { Id = 1, Name = "Mobile", Category = ... Read More

How to subscribe to an Event in C# and can we have multiple subscribers to one Event in a C#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 08:54:19

3K+ Views

Events enable a class or object to notify other classes or objects when something of interest occurs.The class that raises the event is called the publisher and the classes that handle the event are called subscribers.In the EventAn event can have multiple subscribers. A subscriber can handle multiple events from multiple publishers.Events that have no subscribers are never raised.The publisher determines when an event is raised; the subscribers determine what action is taken in response to the event.Exampleclass Program {    static void Main() {       var video = new MP4() { Title = "Eminem" };     ... Read More

What is #if DEBUG and How to use it in C#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 08:49:08

10K+ Views

In Visual Studio Debug mode and Release mode are different configurations for building your .Net project.Select the Debug mode for debugging step by step their .Net project and select the Release mode for the final build of Assembly file (.dll or .exe).The Debug mode does not optimize the binary it produces because the relationship between source code and generated instructions is more complex.This allows breakpoints to be set accurately and allows a programmer to step through the code one line at a time.The Debug configuration of your program is compiled with full symbolic debug information which help the debugger figure ... Read More

What is bin and obj folder in C#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 08:46:35

1K+ Views

Whenever we write a C# code and build or run the solution it generates 2 folders −binobjThese bins and obj has the compiled codeWhy do we have 2 folders?The reason is the compilation process goes through 2 stepscompilinglinkingIn the compiling every individual file is compiled into individual unitsThese compiled files will be later linked into one unit which can be a dll or an exeWhatever happens in the compiled phase will be added into obj folderThe final compilation that is the linked phase will go into bin folderThis obj folder is used in Conditional compilation or incremental compilationEx − I ... Read More

What is the difference between IEnumerable and IQueryable in C#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 08:43:49

10K+ Views

IEnumerable exists in System.Collections Namespace.IQueryable exists in System. Linq Namespace.Both IEnumerable and IQueryable are forward collection.IEnumerable doesn’t support lazy loadingIQueryable support lazy loadingQuerying data from a database, IEnumerable execute a select query on the server side, load data in-memory on a client-side and then filter data.Querying data from a database, IQueryable execute the select query on the server side with all filters.IEnumerable Extension methods take functional objects.IQueryable Extension methods take expression objects means expression tree.ExampleIEnumerabledbContext dc = new dbContext (); IEnumerable list = dc.SocialMedias.Where(p => p.Name.StartsWith("T")); list = list.Take(1); Sql statement generated for the above querySELECT [t0].[ID], [t0].[Name] FROM ... Read More

What is Binary Serialization and Deserialization in C# and how to achieve Binary Serialization in C#?

Nizamuddin Siddiqui
Updated on 05-Aug-2020 08:35:45

3K+ Views

Converting an Object to a Binary format which is not in a human readable format is called Binary Serialization.Converting back the binary format to human readable format is called deserialization?To achieve binary serialization in C# we have to make use of library System.Runtime.Serialization.Formatters.Binary AssemblyCreate an object of BinaryFormatter class and make use of serialize method inside the classExampleSerialize an Object to Binary [Serializable] public class Demo {    public string ApplicationName { get; set; } = "Binary Serialize";    public int ApplicationId { get; set; } = 1001; } class Program {    static void Main()    {     ... Read More

Sum of first N natural numbers which are divisible by 2 and 7 in C++

sudhir sharma
Updated on 05-Aug-2020 08:20:00

176 Views

In this problem, we are given a number N. Our task is to find the sum of first N natural numbers which are divisible by 2 and 7.So, here we will be given a number N, the program will find the sum of numbers between 1 to N that is divisible by 2 and 7.Let’s take an example to understand the problem, Input −N = 10Output −37Explanation −sum = 2 + 4 + 6 + 7 + 8 + 10 = 37So, the basic idea to solve the problem is to find all the numbers that are divisible by 2 ... Read More

Sum of subset differences in C++

sudhir sharma
Updated on 05-Aug-2020 08:18:41

281 Views

In this problem, we are given a set S of n number. Our task is to create a program to find the sum of subset difference which is the difference of last and first elements of subset.The formula is, sumSubsetDifference = Σ [last(s) - first(s)] s are subsets of the set S.Let’s take an example to understand the problem, Input −S = {1, 2, 9} n = 3Output −Explanation − All subset are −{1}, last(s) - first(s) = 0 {2}, last(s) - first(s) = 0 {9}, last(s) - first(s) = 0 {1, 2}, last(s) - first(s) = 1 {1, 9}, last(s) ... Read More

Sum of similarities of string with all of its suffixes in C++

sudhir sharma
Updated on 05-Aug-2020 08:17:23

250 Views

In this problem, we are given string str. Our task is to create a program to find the sum of similarities of the string with all of its suffixes.Suffixes of string str are all the strings that are created by eliminating starting characters of the string.Similarities of string str1 and str2 is the length of the longest prefix common to both the string. For example, str1 = ‘abbac’ and str2 = ‘abb’ is 3.While str1 = ‘abca’ and str2 = ‘ca’ is 0. As we count from start.Let’s take an example to understand the problem, Input − str = ‘xyxyx’Output ... Read More

Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n - 1)^2 in C++

sudhir sharma
Updated on 05-Aug-2020 08:15:45

472 Views

In this problem, we are given a number n of the series. Our task is to find the sum of series 1^2 + 3^2 + 5^2 +... + (2*n - 1)^2 for the given value of n.Let’s take an example to understand the problem,Input −n = 5Output −84Explanation −sum = 1^2 + 3^2 + 5^2 + 7^2 + 9^2 = 1 + 9 + 25 + 49 = 84A basic approach to solve this problem is by directly applying the formula for the sum of series.Example Live Demo#include using namespace std; int calcSumOfSeries(int n) {    int sum = 0;    for (int i = 1; i

Advertisements