Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
QuestionSecondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash9-Sep-15 2:10
santosh kumar dash9-Sep-15 2:10 
AnswerRe: Secondary Y-Axis not displayed in graph using c sharp Pin
Eddy Vluggen9-Sep-15 3:44
professionalEddy Vluggen9-Sep-15 3:44 
GeneralRe: Secondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash10-Sep-15 0:16
santosh kumar dash10-Sep-15 0:16 
Questioncalling T's method from a generic class Pin
binsafir7-Sep-15 23:36
binsafir7-Sep-15 23:36 
AnswerRe: calling T's method from a generic class Pin
Eddy Vluggen7-Sep-15 23:57
professionalEddy Vluggen7-Sep-15 23:57 
AnswerRe: calling T's method from a generic class Pin
Richard MacCutchan7-Sep-15 23:59
mveRichard MacCutchan7-Sep-15 23:59 
AnswerRe: calling T's method from a generic class Pin
Pete O'Hanlon8-Sep-15 0:07
mvePete O'Hanlon8-Sep-15 0:07 
AnswerRe: calling T's method from a generic class Pin
F-ES Sitecore8-Sep-15 0:24
professionalF-ES Sitecore8-Sep-15 0:24 
Generics are functions that work regardless of the type they are bound to. If you need to call a method then your function is no longer generic as it can't be used with any type. In order to do this your types will need to implement an interface that has your method on it

C#
public interface IMyInterface
{
    bool Compare(object target);
}

public class MyClass : IMyInterface
{
    public bool Compare(object target)
    {
        // implement this method properly
        return true;
    }
}


When defining your generic function you can now stipulate that the type used has to implement your interface

C#
private void MyFunction<T>(T data, T data2) where T : IMyInterface
{
    data.Compare(data2);
}


You can now call your generic method but it must be bound to an object that implements your interface, it is no longer 100% generic.

C#
MyFunction<MyClass>(new MyClass(), new MyClass()); // valid
MyFunction<SqlConnection>(new SqlConnection(), new SqlConnection()); // not valid as SqlConnection does not implement IMyInterface

AnswerRe: calling T's method from a generic class Pin
DanBecause9-Sep-15 18:03
DanBecause9-Sep-15 18:03 
GeneralRe: calling T's method from a generic class Pin
David A. Gray11-Sep-15 11:33
David A. Gray11-Sep-15 11:33 
QuestionHow to Insert Into WebServer Using WCF Pin
Käük Kwäý7-Sep-15 17:40
Käük Kwäý7-Sep-15 17:40 
AnswerRe: How to Insert Into WebServer Using WCF Pin
Eddy Vluggen7-Sep-15 23:58
professionalEddy Vluggen7-Sep-15 23:58 
QuestionFormatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 3:52
Ashfaque Hussain7-Sep-15 3:52 
AnswerRe: Formatting the RDL report tablix Pin
Afzaal Ahmad Zeeshan7-Sep-15 9:32
professionalAfzaal Ahmad Zeeshan7-Sep-15 9:32 
GeneralRe: Formatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 21:00
Ashfaque Hussain7-Sep-15 21:00 
QuestionCapturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 17:35
Sultan Uz Zaman6-Sep-15 17:35 
AnswerRe: Capturing from Webcam without preview to the user Pin
Wendelius6-Sep-15 17:43
mentorWendelius6-Sep-15 17:43 
AnswerRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 21:30
mveRichard MacCutchan6-Sep-15 21:30 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:13
Sultan Uz Zaman6-Sep-15 22:13 
GeneralRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 22:34
mveRichard MacCutchan6-Sep-15 22:34 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:43
Sultan Uz Zaman6-Sep-15 22:43 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:11
mvePete O'Hanlon6-Sep-15 23:11 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:15
Sultan Uz Zaman6-Sep-15 23:15 
GeneralRe: Capturing from Webcam without preview to the user Pin
Eddy Vluggen6-Sep-15 23:18
professionalEddy Vluggen6-Sep-15 23:18 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:26
Sultan Uz Zaman6-Sep-15 23:26 

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.