Click here to Skip to main content
15,913,854 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Tuples... Pin
den2k8826-Aug-16 0:46
professionalden2k8826-Aug-16 0:46 
GeneralRe: Tuples... Pin
Rage26-Aug-16 0:58
professionalRage26-Aug-16 0:58 
GeneralRe: Tuples... Pin
den2k8826-Aug-16 1:41
professionalden2k8826-Aug-16 1:41 
GeneralRe: Tuples... Pin
Rage26-Aug-16 1:47
professionalRage26-Aug-16 1:47 
GeneralRe: Tuples... Pin
harold aptroot26-Aug-16 0:48
harold aptroot26-Aug-16 0:48 
GeneralRe: Tuples... Pin
den2k8826-Aug-16 0:53
professionalden2k8826-Aug-16 0:53 
GeneralRe: Tuples... Pin
Sander Rossel26-Aug-16 1:09
professionalSander Rossel26-Aug-16 1:09 
GeneralRe: Tuples... Pin
#realJSOP26-Aug-16 1:32
professional#realJSOP26-Aug-16 1:32 
Tuples are pointless in their current implementation. The size limit is completely arbitrary, and the work around for the size limit is absurd. You'd be better off with a static class that contains a List<object> property. At least that way, you could populate it with a virtually unlimited number of data items, of any type.

Of course, it doesn't have to be static, so if you want persistence, or a unique ObjTuple for given situations, it's easy to code it as needed. I provided the IsString methods to illustrate type-checking that you might want/need. It could be expanded to include all intrinsic types.
C#
public static class ObjTuple
    {
        public static List<object> Objects { get; set; }

<pre>
    public static void Create(params object[] parameters)
    {
        ObjTuple.Objects = (ObjTuple.Objects == null) ? new List&lt;object&gt;() : ObjTuple.Objects;
        ObjTuple.Objects.Clear();
        ObjTuple.Objects.AddRange(parameters);
    }

    private static bool InRange(int index)
    {
        return (index &gt;= 0 &amp;&amp; index &lt; ObjTuple.Objects.Count);
    }

    public static bool IsString(int index)
    {
        return (ObjTuple.InRange(index) &amp;&amp; ObjTuple.IsString(ObjTuple.Objects[index]));
    }

    public static bool IsString(object obj)
    {
        return (obj is string);
    }
}</pre>

Usage would be something like this:
C#
ObjTuple.Create("Test", 1, 5.1);
foreach(object obj in ObjTuple.Objects)
{
    if (ObjTuple.IsString(obj))
    {
        // in this case, this will be true for the first parameter specified
    }
}
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013


modified 26-Aug-16 7:58am.

GeneralRe: Tuples... Pin
Richard Deeming26-Aug-16 2:39
mveRichard Deeming26-Aug-16 2:39 
GeneralRe: Tuples... Pin
#realJSOP26-Aug-16 2:44
professional#realJSOP26-Aug-16 2:44 
GeneralRe: Tuples... Pin
Brady Kelly26-Aug-16 4:15
Brady Kelly26-Aug-16 4:15 
GeneralRe: Tuples... Pin
TheGreatAndPowerfulOz26-Aug-16 4:41
TheGreatAndPowerfulOz26-Aug-16 4:41 
GeneralRe: Tuples... Pin
Brady Kelly26-Aug-16 5:18
Brady Kelly26-Aug-16 5:18 
GeneralRe: Tuples... Pin
TheGreatAndPowerfulOz26-Aug-16 5:59
TheGreatAndPowerfulOz26-Aug-16 5:59 
GeneralRe: Tuples... Pin
BillWoodruff26-Aug-16 15:38
professionalBillWoodruff26-Aug-16 15:38 
GeneralRe: Tuples... Pin
Jörgen Andersson26-Aug-16 1:52
professionalJörgen Andersson26-Aug-16 1:52 
GeneralRe: Tuples... Pin
Brady Kelly26-Aug-16 5:21
Brady Kelly26-Aug-16 5:21 
GeneralRe: Tuples... Pin
Jörgen Andersson26-Aug-16 20:30
professionalJörgen Andersson26-Aug-16 20:30 
GeneralRe: Tuples... Pin
BillWoodruff26-Aug-16 15:44
professionalBillWoodruff26-Aug-16 15:44 
GeneralRe: Tuples... Pin
Jörgen Andersson26-Aug-16 21:44
professionalJörgen Andersson26-Aug-16 21:44 
GeneralFOSW - 26/8/16 - Hint 3 Added Pin
PeejayAdams26-Aug-16 3:52
PeejayAdams26-Aug-16 3:52 
GeneralRe: FOSW - 26/8/16 Pin
Mark Parity26-Aug-16 0:22
Mark Parity26-Aug-16 0:22 
GeneralRe: FOSW - 26/8/16 Pin
PeejayAdams26-Aug-16 0:36
PeejayAdams26-Aug-16 0:36 
GeneralRe: FOSW - 26/8/16 Pin
Mark Parity26-Aug-16 0:48
Mark Parity26-Aug-16 0:48 
GeneralRe: FOSW - 26/8/16 - Hint 1 Added Pin
HobbyProggy26-Aug-16 1:41
professionalHobbyProggy26-Aug-16 1:41 

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.