Click here to Skip to main content
15,398,501 members
Home / Discussions / C#
   

C#

 
JokeRe: How do I keep a player from override another player's move by reclicking a button Pin
Eddy Vluggen1-Feb-14 8:17
professionalEddy Vluggen1-Feb-14 8:17 
GeneralRe: How do I keep a player from override another player's move by reclicking a button Pin
agent_kruger1-Feb-14 18:45
professionalagent_kruger1-Feb-14 18:45 
Questionc# extension methods syntax question Pin
Jon Joeney30-Jan-14 23:23
MemberJon Joeney30-Jan-14 23:23 
AnswerRe: c# extension methods syntax question Pin
harold aptroot31-Jan-14 0:05
Memberharold aptroot31-Jan-14 0:05 
AnswerRe: c# extension methods syntax question Pin
OriginalGriff31-Jan-14 0:23
mveOriginalGriff31-Jan-14 0:23 
GeneralRe: c# extension methods syntax question Pin
BillWoodruff31-Jan-14 5:56
mveBillWoodruff31-Jan-14 5:56 
GeneralRe: c# extension methods syntax question Pin
OriginalGriff31-Jan-14 6:06
mveOriginalGriff31-Jan-14 6:06 
AnswerRe: c# extension methods syntax question Pin
BillWoodruff31-Jan-14 0:57
mveBillWoodruff31-Jan-14 0:57 
One solution would be to make Classes you want to use your extension inherit from a common Interface; Classes that don't inherit from that Interface will then throw a compile-time exception if you try and use the extension with them. Consider:
C#
public interface UseAAAAAAA {}

public static class ExtensionTest
{
    public static String AAAAAAA<T>(this T x) where T : UseAAAAAAA 
    {
        return "Extension Method Test Class: " + typeof(T).Name;
    }
}

public class Test1 : UseAAAAAAA {}

public class Test2 : UseAAAAAAA {}

public class Test3 {}
Test:
Test1 test1 = new Test1();
Test2 test2 = new Test2();
Test3 test3 = new Test3();

Console.WriteLine(test1.AAAAAAA());
Console.WriteLine(test2.AAAAAAA());

// will throw an Error like: Test3' cannot be used as type parameter 'T' in the generic type or method // ExtensionTest.AAAAAAA<T>(T)'. There is no implicit reference conversion from 'Test3' to UseAAAAAAA'
// Console.WriteLine(test3.AAAAAAA());

“But I don't want to go among mad people,” Alice remarked.

“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”

“How do you know I'm mad?” said Alice.

“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll

GeneralRe: c# extension methods syntax question Pin
Richard Deeming31-Jan-14 2:05
mveRichard Deeming31-Jan-14 2:05 
GeneralRe: c# extension methods syntax question Pin
BillWoodruff31-Jan-14 5:48
mveBillWoodruff31-Jan-14 5:48 
AnswerRe: c# extension methods syntax question Pin
Ennis Ray Lynch, Jr.31-Jan-14 9:49
MemberEnnis Ray Lynch, Jr.31-Jan-14 9:49 
QuestionConsole Application c# & use shape & color Pin
vajihe.mirzaei30-Jan-14 5:38
Membervajihe.mirzaei30-Jan-14 5:38 
AnswerRe: Console Application c# & use shape & color Pin
OriginalGriff30-Jan-14 5:57
mveOriginalGriff30-Jan-14 5:57 
AnswerRe: Console Application c# & use shape & color Pin
Dave Kreskowiak30-Jan-14 6:18
mveDave Kreskowiak30-Jan-14 6:18 
AnswerRe: Console Application c# & use shape & color Pin
Rahul VB30-Jan-14 17:45
professionalRahul VB30-Jan-14 17:45 
AnswerRe: Console Application c# & use shape & color Pin
Pete O'Hanlon30-Jan-14 18:55
mvaPete O'Hanlon30-Jan-14 18:55 
GeneralC# Pin
karthick.RR30-Jan-14 2:26
Memberkarthick.RR30-Jan-14 2:26 
GeneralRe: C# Pin
Dave Kreskowiak30-Jan-14 3:30
mveDave Kreskowiak30-Jan-14 3:30 
GeneralRe: C# Pin
Rahul VB30-Jan-14 22:37
professionalRahul VB30-Jan-14 22:37 
GeneralRe: C# Pin
Wayne Gaylard30-Jan-14 22:58
professionalWayne Gaylard30-Jan-14 22:58 
GeneralRe: C# Pin
Rahul VB30-Jan-14 23:44
professionalRahul VB30-Jan-14 23:44 
GeneralRe: C# Pin
agent_kruger31-Jan-14 23:15
professionalagent_kruger31-Jan-14 23:15 
QuestionC# code to check video quality Pin
AshwiniSH29-Jan-14 23:35
professionalAshwiniSH29-Jan-14 23:35 
AnswerRe: C# code to check video quality Pin
Richard MacCutchan30-Jan-14 0:47
mveRichard MacCutchan30-Jan-14 0:47 
AnswerRe: C# code to check video quality Pin
Dave Kreskowiak30-Jan-14 3:29
mveDave Kreskowiak30-Jan-14 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.