Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




What are Generics

We can have an Array List with Integers and a String in it. The technical term for this is "bad." The ArrayList is not type-safe. Type safety enlists the compiler in finding your bugs.

 

Stack <int> st = newStack<int>();

      st.Push(1);

      st.Push(2);

int i = st.Pop();

 

OR

 

class Test<T>

{   

    public T F1(T i)

    {       

        return i;

    }

}

 

Test <int> ob1 = newTest<int>();

      Response.Write(ob1.F1(20));

      Test<string> ob2 = newTest<string>();

Response.Write(ob2.F1("Amit"));

 

Share this article   |    Print    |    Article read by 1057 times
Author:
Guest
Guest user is that user who have done some activity on website without login. Activity contains commenting on any article, uploading an image on website etc.
Related Articles: No related article
Related Interview Questions: No related interview question