Sunday, June 26, 2016

dot net interview questions for experienced professionals

Last Friday I got call from "India Bulls" for telephonic interview as technical round, so in this article I am sharing question of that interview. Firstly interviewer introduce him self and then asked some question related to c#, ASP. net and SQL. The questions are:

Question 1 What is Managed and Unmanaged code?

Question 2 What is Encapsulation and abstraction and difference between them ?

Question 3 What is Interface and abstract class and difference between them ?

Question 4  What is difference between array and array list ?

Question 5  What is Generic and collection ?

Question 6  How to implement interface when both interface have same method name
For Example

Interface I1{ void show();}
Interface I2{ void show();}
Class Test, I1,I2{}    ?

Question 7  What is http handler?

Question 8  What is difference between Response.Write() and Response.OutPut.Write()?

Question 9  What is difference between ViewState and Session?

Question 10  What is Transaction Management?

Question 11  Type of Temporary Table in SQL?

Question 12 Difference between truncate and delete?

Question 13 Difference between Stuff() and Replace() function in SQL?

Question 14 Which one query executed fast and Why?

Query 1 select count(*)  from table name

Query 2 select Count(Id) from table name

Query 3 select Count(1) from table name


Question 15  How to insert into table though xml?

Question 16  What is static class in c#?

Question 17  Explain constraints in SQL?

Friday, June 24, 2016

Sql combine multiple rows into one string

In this article I am going to explain how to show multi row column value into single row in sql.


Output

Thursday, June 23, 2016

Running sum in sql server

In this article, I am going to explain how to calculate running or cumulative sum in SQL



Output

Calculate hours minutes between two dates in SQL

In this article, I am going to create logic how to calculate hours and minute between two dates in SQL.

DECLARE @date1 DATETIME = '2016-06-23 12:18:03.133';
DECLARE @date2 DATETIME = getdate();
SELECT CAST((DATEDIFF(Minute, @date1, @date2)) / 60 AS VARCHAR(5)) + ' Hrs' + ' ' + RIGHT('0' + CAST((DATEDIFF(Minute, @date1, @date2)) % 60 AS VARCHAR(2)), 2) + ' Min' AS 'TotalTime'


Output

Sunday, June 19, 2016

Image width and height in asp.net c#

In this article, I am going to explain how to find out uploaded image dimension in asp. net c#.

Code of aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:FileUpload ID="fupload" runat="server" />
    <asp:Button ID="btnCheckHeightWidth" runat="server" Text="Check"
            onclick="btnCheckHeightWidth_Click" /><asp:Label ID="lblmsg" runat="server" ForeColor="Green"></asp:Label>
    </div>
    </form>
</body>
</html>

Code of cs page

using System;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void btnCheckHeightWidth_Click(object sender, EventArgs e)
    {
        System.IO.Stream stream = fupload.PostedFile.InputStream;
        System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
        lblmsg.Text = "Image size is " + image.Width + "x" + image.Height + " px";
    }
}

Image


Output


Friday, June 17, 2016

update controls outside updatepanel c#

In this article, I am going to explain how to update Control value or any other ASP. net control which reside out side update panel.

Let's take a example, suppose I have a button inside update panel and click on that button I want to assign some value in textbox.

Here the aspx Code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scmain" runat="server"></asp:ScriptManager>
 
    <asp:UpdatePanel ID="upmain" runat="server">
    <ContentTemplate>
     <fieldset>
    <legend>Button Inside Update Panel</legend>
    <asp:Button ID="btnUpdateValue" runat="server" Text="UpdateValue"
             onclick="btnUpdateValue_Click" />
    </fieldset>
    </ContentTemplate>
    </asp:UpdatePanel>
 
     <asp:UpdatePanel ID="uptextbox" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <fieldset>
    <legend>Out Side TextBox of Update Panal</legend>
    <asp:TextBox ID="txtvalue" runat="server"></asp:TextBox>
    </fieldset>
    </ContentTemplate>
    </asp:UpdatePanel>
 
    </form>
</body>
</html>

Here the aspx.cs Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void btnUpdateValue_Click(object sender, EventArgs e)
    {
        txtvalue.Text = "Verified";
        uptextbox.Update();
    }
}

Output




Saturday, June 11, 2016

Write a program to find GCD of 2 numbers in C#.NET



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main()
        {
            int i, i1;

            Console.WriteLine("Enter 2 numbers to find GCD");
            i = int.Parse(Console.ReadLine());
            i1 = int.Parse(Console.ReadLine());

            int num, num1;
      
            if (i > i1)
            {
                num = i;
                num1 = i1;
            }
            else
            {
                num = i1;
                num1 = i;
            }
            int output = gcd(num, num1);
            Console.WriteLine("The GCD of {0} and {1} is {2}", i, i1, output);
            Console.Read();
        }

        private static int gcd(int num, int num1)
        {
            int rem = 5;
            while (num1 > 0)
            {
                rem = num % num1;
                if (rem == 0)
                    return num1;
                num = num1;
                num1 = rem;

            }

            return num;

        }
    }
}

Output : 



Wednesday, June 8, 2016

Write a Program to convert Decimal to Binary in C#.NET

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication16
{
    class Program
    {
        static void Main()
        {
            int num;
            Console.Write("Enter a Number : ");
            num = int.Parse(Console.ReadLine());
            int q;
 
            string rem = "";
 
            while (num >= 1)
            {
                q = num / 2;
                rem += (num % 2).ToString();
                num = q;
            }
 
 
            string b = "";
            for (int i = rem.Length - 1; i >= 0; i--)
            {
                b = b + rem[i];
 
            }
 
            Console.WriteLine("The Binary num of given number is {0}", b);
 
 
            Console.Read();
 
        }
    }

}

Output :

Tuesday, June 7, 2016

Write program to find LCM of 2 numbers in C# .NET

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication15
{
    public class LCM
    {
        public static int dLCM(int a, int b)
        {
            int n1, n2;
            if (a > b)
            {
                n1 = a; n2 = b;
            }
            else
            {
                n1 = b; n2 = a;
            }
 
            for (int i = 1; i <= n2; i++)
            {
                if ((n1 * i) % n2 == 0)
                {
                    return i * n1;
                }
            }
            return n2;
        }
 
        public static void Main(String[] args)
        {
            int n01, n02;
 
            Console.WriteLine("Enter 2 numbers :");
 
            n01 = int.Parse(Console.ReadLine());
            n02 = int.Parse(Console.ReadLine());
 
            int l = dLCM(n01, n02);
 
            Console.WriteLine("LCM of {0} and {1} is {2}", n01, n02, l);
            Console.Read();
        }
    }

}

Output :