Click here to Skip to main content
15,918,889 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Convert C++ unsigned char * to C# byte[] Pin
Joe Rozario25-Apr-10 22:42
Joe Rozario25-Apr-10 22:42 
GeneralRe: How to Convert C++ unsigned char * to C# byte[] Pin
Michel Godfroid25-Apr-10 23:45
Michel Godfroid25-Apr-10 23:45 
AnswerRe: How to Convert C++ unsigned char * to C# byte[] Pin
Luc Pattyn26-Apr-10 0:58
sitebuilderLuc Pattyn26-Apr-10 0:58 
QuestionSaving the execution of website as XML file Pin
aforaries25-Apr-10 10:41
aforaries25-Apr-10 10:41 
AnswerRe: Saving the execution of website as XML file Pin
Ravi Bhavnani25-Apr-10 15:41
professionalRavi Bhavnani25-Apr-10 15:41 
AnswerRe: Saving the execution of website as XML file Pin
Luc Pattyn25-Apr-10 16:26
sitebuilderLuc Pattyn25-Apr-10 16:26 
GeneralRe: Saving the execution of website as XML file Pin
aforaries25-Apr-10 23:59
aforaries25-Apr-10 23:59 
GeneralRe: Saving the execution of website as XML file Pin
Luc Pattyn26-Apr-10 0:41
sitebuilderLuc Pattyn26-Apr-10 0:41 
QuestionHow to extract data from DataGridView in csharp smart device????? Pin
Tunisien8625-Apr-10 8:34
Tunisien8625-Apr-10 8:34 
AnswerRe: How to extract data from DataGridView in csharp smart device????? Pin
Michel Godfroid25-Apr-10 10:00
Michel Godfroid25-Apr-10 10:00 
QuestionAssign a variable a series of values Pin
Wogboiii25-Apr-10 3:41
Wogboiii25-Apr-10 3:41 
AnswerRe: Assign a variable a series of values Pin
#realJSOP25-Apr-10 3:49
professional#realJSOP25-Apr-10 3:49 
GeneralRe: Assign a variable a series of values Pin
Wogboiii25-Apr-10 3:51
Wogboiii25-Apr-10 3:51 
GeneralRe: Assign a variable a series of values Pin
PIEBALDconsult25-Apr-10 5:38
mvePIEBALDconsult25-Apr-10 5:38 
AnswerRe: Assign a variable a series of values [modified] Pin
PIEBALDconsult25-Apr-10 4:03
mvePIEBALDconsult25-Apr-10 4:03 
GeneralRe: Assign a variable a series of values Pin
Wogboiii25-Apr-10 4:06
Wogboiii25-Apr-10 4:06 
GeneralRe: Assign a variable a series of values Pin
PIEBALDconsult25-Apr-10 4:20
mvePIEBALDconsult25-Apr-10 4:20 
AnswerRe: Assign a variable a series of values Pin
Moreno Airoldi25-Apr-10 4:40
Moreno Airoldi25-Apr-10 4:40 
You can get what you need with generic programming and OOP.
This is a raw example:

public class MultiVar<T>
{
    private List<T> Values = new List<T>();
    private int ValuePointer = -1;

    public MultiVar()
    {
    }

    public MultiVar(T FirstValue)
    {
        Values.Add(FirstValue);
    }

    public void AddValue(T Value)
    {
        Values.Add(Value);
    }

    public T GetValue()
    {
        if (Values.Count < 1) throw new ApplicationException("Empty value set.");
        if (++ValuePointer >= Values.Count) ValuePointer = 0;
        return Values[ValuePointer];
    }

    public static implicit operator T(MultiVar<T> Object)
    {
        return Object.GetValue();
    }
}


You can check it with:

MultiVar<int> mymultivar = new MultiVar<int>();
for (int i = 10; i < 110; i += 10) mymultivar.AddValue(i);

for (int i = 0; i < 15; i++)
{
    Console.Write(" ");
    Console.Write((int)mymultivar);
}
Console.WriteLine();


The result is:

10 20 30 40 50 60 70 80 90 100 10 20 30 40 50


Just add code to remove values, if you need it, and customize as needed.
Enjoy! Smile | :)
2+2=5 for very large amounts of 2
(always loved that one hehe!)

GeneralRe: Assign a variable a series of values Pin
harold aptroot25-Apr-10 4:42
harold aptroot25-Apr-10 4:42 
GeneralRe: Assign a variable a series of values Pin
PIEBALDconsult25-Apr-10 4:56
mvePIEBALDconsult25-Apr-10 4:56 
GeneralRe: Assign a variable a series of values Pin
Moreno Airoldi25-Apr-10 6:21
Moreno Airoldi25-Apr-10 6:21 
GeneralRe: Assign a variable a series of values Pin
Moreno Airoldi25-Apr-10 6:21
Moreno Airoldi25-Apr-10 6:21 
GeneralRe: Assign a variable a series of values Pin
harold aptroot25-Apr-10 6:26
harold aptroot25-Apr-10 6:26 
GeneralRe: Assign a variable a series of values Pin
Moreno Airoldi25-Apr-10 6:33
Moreno Airoldi25-Apr-10 6:33 
GeneralRe: Assign a variable a series of values Pin
PIEBALDconsult25-Apr-10 6:42
mvePIEBALDconsult25-Apr-10 6:42 

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.