Skip to content

Instantly share code, notes, and snippets.

@shoupn shoupn/generics.cs
Last active Mar 23, 2019

Embed
What would you like to do?
class GenericClass<T> where T
{
private T _genericField;
public T genericProperty { get; set; }
public GenericClass(T value)
{
_genericField = value;
}
public T genericMethod(T genericParameter)
{
this.genericProperty = genericParameter;
Console.WriteLine("Parameter type: {0}, value: {1}", typeof(T).ToString(), genericParameter);
Console.WriteLine("Return type: {0}, value: {1}", typeof(T).ToString(), this._genericField);
return this._genericField;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.