
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1629 of 2650

10K+ Views
Inner join returns only those records or rows that match or exists in both the tables. We can also apply to join on multiple tables based on conditions as shown below. Make use of anonymous types if we need to apply to join on multiple conditions.In the below example we have written 2 ways that can be used to join in Linq Here the Department and the Employee are joinedExampleclass Program{ static void Main(string[] args){ var result = Employee.GetAllEmployees().Join(Department.GetAllDepartments(), e => e.DepartmentID, d => d.ID, (employee, department) ... Read More

2K+ 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).To change the build configuration −From the Build menu, select Configuration Manager, then select Debug or Release. Or On the toolbar, choose either Debug or Release from the Solution Configurations list.The code which is written inside the #if debug will be executed only if the code is running inside the debug mode.If the code is running in the release ... Read More

7K+ Views
A Unix timestamp is mainly used in Unix operating systems. But it is helpful for all operating systems because it represents the time of all time zones.Unix Timestamps represent the time in seconds. The Unix epoch started on 1st January 1970.So, Unix Timestamp is the number of seconds between a specific dateExampleto get the Unix Timestamp Using DateTime.Now.Subtract().TotalSeconds Methodclass Program{ static void Main(string[] args){ Int32 unixTimestamp = (Int32)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; Console.WriteLine("The Unix Timestamp is {0}", unixTimestamp); Console.ReadLine(); } }Output1596837896Exampleto get the Unix Timestamp Using DateTimeOffset.Now.ToUnixTimeSeconds() ... Read More

2K+ Views
Yes it is possible to force garbage collector in C# to run by calling Collect() methodThis is not considered a good practice because this might create a performance over head. Collect() Forces an immediate garbage collection of all generations.Collect(Int32)Forces an immediate garbage collection from generation 0 through a specified generation.Example Live Demousing System; class MyGCCollectClass{ private const int maxGarbage = 1000; static void Main(){ // Put some objects in memory. MyGCCollectClass.MakeSomeGarbage(); Console.WriteLine("Memory used before collection: {0:N0}", GC.GetTotalMemory(false)); // Collect all generations of memory. ... Read More

763 Views
We can create an array with non-default values using Enumerable.Repeat(). It repeated a collection with repeated elements in C#. Firstly, set which element you want to repeat and how many times.Example 1class Program{ static void Main(string[] args){ var values = Enumerable.Repeat(10, 5); foreach (var item in values){ System.Console.WriteLine(item); } Console.ReadLine(); } }Output10 10 10 10 10Example 2class Program{ static void Main(string[] args){ int[] values = Enumerable.Repeat(10, 5).ToArray(); foreach (var item in values){ System.Console.WriteLine(item); } Console.ReadLine(); } }Output10 10 10 10 10

170 Views
We are creating two instances of the Employee class, e and e1. The e is assigned to e1. Both objects are pointing to the same reference, hence we will get true as expected output for all the Equals.In the second case we can observe that, even though properties values are same. Equals returns false. Essentially, when arguments are referring to different objects. Equals don’t check for the values and always returns false.Example 1class Program{ static void Main(string[] args){ Employee e = new Employee(); e.Name = "Test"; e.Age = 27; ... Read More

3K+ Views
The Take operator is used to return a given number of elements from an array and the Skip operator skips over a specified number of elements from an array.Skip, skips elements up to a specified position starting from the first element in a sequence.Take, takes elements up to a specified position starting from the first element in a sequence.Example 1class Program{ static void Main(string[] args){ List numbers = new List { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 5, 6, 7, ... Read More

1K+ Views
Shallow Copy −A shallow copy of an object copies the "main" object, but doesn’t copy the inner objects.The "inner objects" are shared between the original object and its copy.The problem with the shallow copy is that the two objects are not independent. If you modify the one object, the change will be reflected in the other object.Deep Copy −A deep copy is a fully independent copy of an object. If we copied our object, we would copy the entire object structure.If you modify the one object, the change will not be reflected in the other object.Exampleclass Program{ static void ... Read More

1K+ Views
Action filters are used to add extra logic before or after action methods execution. The OnActionExecuting and OnActionExecuted methods are used to add our logic before and after an action method is executed.Let us create create a LogAttribute that implemets ActionFilterAttribute which logs some information before and after action method execution.LogAttribute −Exampleusing System; using System.Diagnostics; using System.Web.Http.Controllers; using System.Web.Http.Filters; namespace DemoWebApplication.Controllers{ public class LogAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext){ Debug.WriteLine(string.Format("Action Method {0} executing at {1}", actionContext.ActionDescriptor.ActionName, DateTime.Now.ToShortDateString()), ... Read More

300 Views
Media types allow an API to inform the client how to interpret the data in the payload. In the HTTP protocol, Media Types are specified with identifiers like text/html, application/json, and application/xml, which correspond to HTML, JSON, and XML respectively, the most common web formats. There are other more APIspecific Media Types as well, such as application/vnd.api+json.Below are versions that needs to be send in media types.application/vnd.demo.students.v1+json StudentsV1Controller application/vnd.demo.students.v2+json StudentsV2ControllerAdding our own CustomControllerSelector will fix the above error.CustomControllerSelector −Exampleusing System.Linq; using System.Net.Http; using System.Text.RegularExpressions; using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Dispatcher; namespace WebAPI.Custom{ public class CustomControllerSelector : DefaultHttpControllerSelector{ ... Read More