| Next Tip?

CSharp, Microsoft .Net »

[22 May 2011 | No Comment | 912 views]

We have many books around, anyone can get a definition of interface which is nothing but bookish. In these days we are more interested to know what you know about interfaces rather than what you read for interfaces?
Here, I tried to cover interfaces in my own words:
Interface
An interface is simply a collection of function prototypes. An Interface is a reference type like a class, but interface can contain only abstract members. In other words, Interface is a contract that defines the signature of the functionality.
An interface looks like a class …

CSharp, Microsoft .Net »

[18 May 2011 | No Comment | 560 views]

A very basic and common questions asked many time to freshers, novoice or intermediate level interviews. I got many emails for the same questions, hereunder I try to answer in a simpler way.
Structures
A structure in C# is simply a composite data type [you are well aware from composite data type, refer to data types for more details], which consists number of members of other types. The structure define simply by using the struct keyword.
eg. struct enroll
{
   public string name, fname, mname;
   public string char sex;
   Public int age;
   public string address;
}
Classes
It is cleared from …

General »

[29 Apr 2010 | No Comment | 2,231 views]

Yes, its possible to create constructors for Abstract classes. We can create Private, Public and Protected constructors for Abstract classes
Example:
Abstract class  myAbstClass
{
public myAbstClass()
{ }
private myAbstClass(int x)
{ //some implementation }
protected myAbstClass(string strX, string strY, int x)
{ //some implementation }
}
Tweet This Post

Database Questions, MsSql Server »

[8 Feb 2010 | One Comment | 1,969 views]

This question is asked in recent interview, following is the scenario:
Q. I have a following table :

University
UtoTal
Status
StatusCnt

U1
100
Pending
20

U1
100
Active
20

U1
100
Deferred
60

U2
60
Pending
20

U2
60
Active
20

U2
60
Deferred
20

I want results as :

University
UtoTal
Status
StatusCnt

U1
100
Pending
20

Active
20

Deferred
60

U2
60
Pending
20

Active
20

Deferred
20

Ans: At the time of interview I wasn’t easy with the answer but I wrote a query, but interviewer not satisfied.
I got the following proper query/solution from one of my colleagues Mr. sandeep Walia:
declare @tbl table(university varchar(100),Utotals int, status varchar(100),statuscnt int)
insert into @tbl(university,Utotals,status,statuscnt)
select ‘u1′,100,’pending’,20
union all
select ‘u1′,100,’Active’,20
union all
select ‘u1′,100,’Deferred’,60
union all
select ‘u2′,60,’pending’,20
union all
select ‘u2′,60,’Active’,20
union all
select ‘u2′,60,’Deferred’,20
select * from @tbl;
with cte as (
SELECT ROW_NUMBER() OVER(PARTITION BY university ORDER BY university DESC) AS RowID,
*
FROM …

Database Questions, MsSql Server »

[4 Feb 2010 | One Comment | 1,725 views]

Q. Here is the scenario:

declare @tt table(col1 varchar(10), joinexp varchar(100))
insert into @tt
select ‘c1′,’join table2 on table1.id = table1.id’
union all
select ‘c2′,’join table3 on table2.id = table1.id’
union all
select ‘c3′,’join table4 on table3.id = table1.id’
union all
select ‘c4′,’join table5 on table5.id = table1.id’
union all
select ‘c5′,NULL
union all
select ‘c6′,NULL
declare @str varchar(1000)
set @str = ‘Select c1,c4,c5,c8,c9 from table1′
declare @tt table(col1 varchar(10), joinexp varchar(100))insert into @ttselect ‘c1′,’join table2 on table1.id = table1.id’union allselect ‘c2′,’join table3 on table2.id = table1.id’union allselect ‘c3′,’join table4 on table3.id = table1.id’union allselect ‘c4′,’join table5 on table5.id = table1.id’union allselect ‘c5′,NULLunion allselect ‘c6′,NULL
declare @str …