Click here to Skip to main content
15,905,238 members
Home / Discussions / C#
   

C#

 
GeneralRe: ClickOnce : Unknown Publisher Pin
Jaimesh.241110-May-16 1:54
Jaimesh.241110-May-16 1:54 
GeneralRe: ClickOnce : Unknown Publisher Pin
Pete O'Hanlon10-May-16 2:26
mvePete O'Hanlon10-May-16 2:26 
GeneralRe: ClickOnce : Unknown Publisher Pin
Jaimesh.241110-May-16 2:34
Jaimesh.241110-May-16 2:34 
GeneralRe: ClickOnce : Unknown Publisher Pin
Pete O'Hanlon10-May-16 3:02
mvePete O'Hanlon10-May-16 3:02 
QuestionBest method to automate website filling in Google Chrome Pin
srikrishnathanthri8-May-16 23:26
srikrishnathanthri8-May-16 23:26 
AnswerRe: Best method to automate website filling in Google Chrome Pin
Richard MacCutchan8-May-16 23:56
mveRichard MacCutchan8-May-16 23:56 
GeneralRe: Best method to automate website filling in Google Chrome Pin
srikrishnathanthri9-May-16 0:02
srikrishnathanthri9-May-16 0:02 
GeneralRe: Best method to automate website filling in Google Chrome Pin
Richard MacCutchan9-May-16 0:18
mveRichard MacCutchan9-May-16 0:18 
Answer[REPOST] Best method to automate website filling in Google Chrome Pin
Richard Deeming9-May-16 1:55
mveRichard Deeming9-May-16 1:55 
QuestionReports in Visual studio 2012 -Display footer on last page Pin
Member 124156218-May-16 23:13
Member 124156218-May-16 23:13 
QuestionMultilingua virtual keyboard Pin
kelkeel7-May-16 19:44
kelkeel7-May-16 19:44 
AnswerRe: Multilingua virtual keyboard Pin
Peter_in_27807-May-16 21:00
professionalPeter_in_27807-May-16 21:00 
GeneralRe: Multilingua virtual keyboard Pin
kelkeel7-May-16 22:00
kelkeel7-May-16 22:00 
AnswerRe: Multilingua virtual keyboard Pin
OriginalGriff7-May-16 22:22
mveOriginalGriff7-May-16 22:22 
GeneralRe: Multilingua virtual keyboard Pin
kelkeel7-May-16 23:21
kelkeel7-May-16 23:21 
GeneralRe: Multilingua virtual keyboard Pin
OriginalGriff7-May-16 23:32
mveOriginalGriff7-May-16 23:32 
GeneralRe: Multilingua virtual keyboard Pin
kelkeel7-May-16 23:59
kelkeel7-May-16 23:59 
GeneralRe: Multilingua virtual keyboard Pin
OriginalGriff8-May-16 0:15
mveOriginalGriff8-May-16 0:15 
GeneralRe: Multilingua virtual keyboard Pin
Peter_in_27808-May-16 12:00
professionalPeter_in_27808-May-16 12:00 
GeneralRe: Multilingua virtual keyboard Pin
Mycroft Holmes8-May-16 22:32
professionalMycroft Holmes8-May-16 22:32 
GeneralRe: Multilingua virtual keyboard Pin
kelkeel8-May-16 23:04
kelkeel8-May-16 23:04 
GeneralRe: Multilingua virtual keyboard Pin
kelkeel8-May-16 17:37
kelkeel8-May-16 17:37 
AnswerRe: Multilingua virtual keyboard Pin
Bernhard Hiller8-May-16 20:48
Bernhard Hiller8-May-16 20:48 
QuestionOverloading default member in a C# class Pin
Kenneth Haugland7-May-16 19:25
mvaKenneth Haugland7-May-16 19:25 
So I basically have a Complex Matrix class like so:
C#
public struct ComplexMatrix
{
    private int Rows;
    private int Cols;

    private Complex[,] matrix;
    public ComplexMatrix(int Rows, int Cols)
    {
        this.Rows = Rows;
        this.Cols = Cols;
        Complex[,] temp = new Complex[Rows, Cols];
        this.matrix = temp;
        for (int i = 0; i <= Rows - 1; i++)
        {
            for (int j = 0; j <= Cols - 1; j++)
            {
                matrix[i, j] = new Complex(0, 0);
            }
        }
    }

    public Complex this[int Row, int Col]
    {
        get { return matrix[Row, Col]; }
        set { matrix[Row, Col] = value;}
    }
...

However, Im a bit lazy so I would really like to set matrix items as follows:
MyMatrix[1, 1] = new Complex(1, 0);
MyMatrix[0, 1] = 1;
MyMatrix[1, 0] = 5d;

But I found no easy way of doing this. I basically want the setter of the property to be able to take an object, but the get function will always return a Complex.

I could of curse do this:
C#
public object this[int Row, int Col]
{
    get { return matrix[Row, Col]; }
    set
    {
        if (value is Complex)
        {
            matrix[Row, Col] = (Complex)value;

        }
        else if (value is double)
        {
            matrix[Row, Col] = new Complex((double)value, 0);
        }
        else if (value is int)
        {
            matrix[Row, Col] = new Complex((double)((int)value), 0);
        }
        else
        {
            throw new NotSupportedException("Not supported");
        }

    }
}

But that is really cumbersome when you want to get the value. Is there any tricks I could use to make this work properly?
AnswerRe: Overloading default member in a C# class Pin
Kenneth Haugland7-May-16 20:34
mvaKenneth Haugland7-May-16 20:34 

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.