
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
Found 33676 Articles for Programming

4K+ Views
The NonAction attribute is used when we want a public method in a controller but do not want to treat it as an action method. An action method is a public method in a controller that can be invoked using a URL. So, by default, if we have any public method in a controller then it can be invoked using a URL request. To restrict access to public methods in a controller, NonAction attribute can be used.Now let us consider HomeController having two public methods MyMethod1 and MyMethod2.ControllerExampleusing System.Web.Mvc; namespace DemoMvcApplication.Controllers{ public class HomeController : Controller{ ... Read More

4K+ Views
ViewBag uses the dynamic feature that was introduced in to C# 4.0. It allows an object to have properties dynamically added to it. Internally, it is a dynamic type property of the ControllerBase class which is the base class of the Controller class.ViewBag only transfers data from controller to view, not visa-versa. ViewBag values will be null if redirection occurs. ViewBag is able to set and get value dynamically and able to add any number of additional fields without converting it to strongly typed.Storing data in ViewBag −ViewBag.Counties = countriesList;Retrieving data from ViewBag −string country = ViewBag.Countries;ControllerExampleusing System.Collections.Generic; using System.Web.Mvc; ... Read More

13K+ Views
A regular expression is a pattern that could be matched against an input text. The .Net framework provides a regular expression engine that allows such matching. A pattern consists of one or more character literals, operators, or constructs.Here are basic pattern metacharacters used by RegEx −* = zero or more ? = zero or one ^ = not [] = rangeThe ^ symbol is used to specify not condition.the [] brackets if we are to give range values such as 0 - 9 or a-z or A-ZUsing Char.IsDigit()Example Live Demousing System; namespace DemoApplication{ public class Program{ static ... Read More

756 Views
A message handler is a class that receives an HTTP request and returns an HTTP response. Message handlers derive from the abstract HttpMessageHandler class. Message handlers provide us the opportunity to process, edit, or decline an incoming request before it reaches the HttpControllerDispatcher.Message handlers are executed much earlier in the request processing pipeline, hence they are a great place to implement cross cutting concerns in Web API. Message Handlers are nothing but a chain of classes (it may be system defined or defined by us) that sits next to the process of HTTP request and response through a pipeline.For example, ... Read More

7K+ Views
To calculate the length of a Linked list, we traverse the list, counting each node until we reach the end, where the next node is None. Suppose, we have a singly linked list, we have to find its length. The linked list has fields next and val. So, if the input is like [2 -> 4 -> 5 -> 7 -> 8 -> 9 -> 3], then the output will be 7. The two commonly used methods to find the length of a linked list are as follows - ... Read More

1K+ Views
The Latin square is a matrix that has a special pattern. Let's see different examples to examine the pattern.1 2 2 1 1 2 3 3 1 2 2 3 1 1 2 3 4 4 1 2 3 3 4 1 2 2 3 4 1 The Latin square that you get will be of different size as you notice in the above examples. But, if you carefully observe the above matrices' pattern, you will find out that the last number of the previous row comes as the first element of the next row.That's the pattern ... Read More

341 Views
Suppose we have two numbers num and k, we have to find the largest product of k contiguous digits in num. We have to keep in mind that num is guaranteed to have >= k digits.So, if the input is like num = 52689762 and k = 4, then the output will be 3024, largest product of 4 consecutive digits is (8*9*7*6) = 3024.To solve this, we will follow these steps −largest := 0cand := 1while (quotient of num/10)^(k-1) > 0, dodigits := (last digit of nums)^kcand := 1while digits > 0, docand := cand * (digits mod 10)if cand ... Read More

287 Views
Suppose we have a list of numbers; we have to check whether the largest number is bigger than the second-largest number by more than two times. As an example, if the list is like [3, 9, 6], then it will return false, as 9 is not bigger than 12 (2 times 6). When the list is [6, 3, 15], it will return true, as 15 is bigger than 12 (2 times 6).To solve this, we will follow these steps −if size of nums < 2, thenreturn Falsep_max := minimum of nums[0] and nums[1]c_max := maximum of nums[0] and nums[1]for i ... Read More

1K+ Views
Suppose we have a list of numbers called nums, we have to find the largest difference of two consecutive numbers in the sorted version of nums.So, if the input is like [5, 2, 3, 9, 10, 11], then the output will be 4, as the largest gap between 5 and 9 is 4.To solve this, we will follow these steps −n := sorted list numsans := a new listfor i in range 0 to size of n -2, doinsert n[i+1]-n[i] at the end of ansreturn maximum of ansLet us see the following implementation to get better understanding −Example Live Democlass Solution: ... Read More

441 Views
Suppose we have a list of numbers nums and an integer k, we have to find the maximum possible i where nums[0] + nums[1] + ... + nums[i] ≤ k. We will return -1 if no valid i exists.So, if the input is like nums = [4, -7, 5, 2, 6], k = 5, then the output will be 3, the index is 3 as if we add 4+(-7)+5+2 = 4, this is less than k, if we add last element it will no longer less than k, so the index is 3.To solve this, we will follow these steps ... Read More