Found 26504 Articles for Server Side Programming

What is Lambda expression in C#?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:50:58

592 Views

Lambda expression is a better way to represent an anonymous method. Both anonymous methods and Lambda expressions allow you define the method implementation inline, however, an anonymous method explicitly requires you to define the parameter types and the return type for a method.Expression lambda that has an expression as its body: (input−parameters) => expressionStatement lambda that has a statement block as its body: (input−parameters) => { }Any lambda expression can be converted to a delegate type. The delegate type to which a lambda expression can be converted is defined by the types of its parameters and return value. If ... Read More

How to check in C# whether the string array contains a particular work in a string array?

Nizamuddin Siddiqui
Updated on 04-Oct-2023 21:43:08

33K+ Views

In C#, String.Contains() is a string method. This method is used to check whether the substring occurs within a given string or not. It returns the boolean value. If substring exists in string or value is the empty string (""), then it returns True, otherwise returns False. Exception − This method can give ArgumentNullException if str is null. This method performs the case-sensitive checking. The search will always begin from the first character position of the string and continues until the last character position. Example 1 Contains is case sensitive if the string is found it return true else false ... Read More

How to use “not in” query with C# LINQ?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:48:09

7K+ Views

Except operator are designed to allow you to query data which supports the IEnumerable

What is the difference between the | and || or operators in C#?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:46:18

2K+ Views

| OperatorThe | operator computes the logical OR of its operands. The result of x | y is true if either x or y evaluates to true. Otherwise, the result is false.The | operator evaluates both operands even if the left-hand operand evaluates to true, so that the operation result is true regardless of the value of the right-hand operand.|| OperatorThe conditional logical OR operator ||, also known as the "short−circuiting" logical OR operator, computes the logical OR of its operands.The result of x || y is true if either x or y evaluates to true. Otherwise, the result is ... Read More

How to get the ip address in C#?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:44:33

1K+ Views

IP (Internet Protocol) Address is an address of your network hardware. It helps in connecting your computer to other devices on your network and all over the world. An IP Address is made up of numbers or characters.All devices that are connected to an internet connection have a unique IP address which means there’s a need of billions of IP addresses. This requirement is fulfilled by the new IP version IPv6.Private IP AddressA private IP address is the address of your device connected on the home or business network. If you have a few different devices connected to one ISP ... Read More

How to Deserializing JSON to .NET object using Newtonsoft json in C# and pick only one value from the array?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:42:44

579 Views

The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.The WebClient class uses the WebRequest class to provide access to resources. WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.DownloadString Downloads a String from a resource and returns a String.If your request requires an optional header, you must add the header to the Headers collectionExampleIn the below example we are calling the url "https://jsonplaceholder.typicode.com/posts"The example is then deserialized to User arrayFrom the user array we are printing the first array valueExampleclass ... Read More

How do I overload the [] operator in C#?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:40:59

328 Views

The [] operator is called an indexer.An indexer allows an object to be indexed such as an array. When you define an indexer for a class, this class behaves similar to a virtual array. You can then access the instance of this class using the array access operator ([ ]).Indexers can be overloaded. Indexers can also be declared with multiple parameters and each parameter may be a different type. It is not necessary that the indexes have to be integers.Example 1static void Main(string[] args){    IndexerClass Team = new IndexerClass();    Team[0] = "A";    Team[1] = "B";    Team[2] ... Read More

How to check whether you are connected to Internet or not in C#?

Nizamuddin Siddiqui
Updated on 05-Nov-2020 13:37:58

1K+ Views

There are many ways to check whether internet is connected to a machine in C# or not. Make use of System.Net namespace which provides common methods for sending data to and receiving data from a resource identified by a URI. The WebClient or HttpClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI. Here in the below example we have used (OpenRead)Returns the data from a resource as a Stream.Checks by hitting the url "http://google.com/generate_204" if success return true else false.The below example runs in the loop ... Read More

How to select a Subset Of Data Using lexicographical slicingin Python Pandas?

Kiran P
Updated on 10-Nov-2020 09:34:45

319 Views

IntroductionPandas have a dual selection capability to select the subset of data using the Index position or by using the Index labels. Inthis post, I will show you how to "Select a Subset Of Data Using lexicographical slicing".Google is full of datasets. Search for movies dataset in kaggle.com. This post uses the movies data set from kaggle.How to do it1. Import the movies dataset with only the columns required for this example.import pandas as pd import numpy as np movies = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/movies_data.csv", index_col="title", usecols=["title", "budget", "vote_average", "vote_count"]) movies.sample(n=5)titlebudgetvote_averagevote_countLittle Voice06.661Grown Ups 2800000005.81155The Best Years of Our Lives21000007.6143Tusk28000005.1366Operation Chromite05.8292. I always recommend ... Read More

How to select subset of data with Index Labels in Python Pandas?

Kiran P
Updated on 10-Nov-2020 06:32:47

1K+ Views

IntroductionPandas have a dual selection capability to select the subset of data using the Index position or by using the Index labels. Inthis post, I will show you how to “Select a Subset Of Data Using Index Labels” using the index label.Remember, Python dictionaries and lists are built-in data structures that select their data either by using the index label or byindex position. A dictionary’s key must be a string, integer, or tuple while a List must either use integers (the position) or sliceobjects for selection.Pandas have .loc and.iloc attributes available to perform index operations in their own unique ways. ... Read More

Advertisements