Click here to Skip to main content
15,909,835 members
Home / Discussions / C#
   

C#

 
GeneralRe: Stupid question of the day (Trees) Pin
Pete O'Hanlon2-Apr-08 3:05
mvePete O'Hanlon2-Apr-08 3:05 
GeneralRe: Stupid question of the day (Trees) Pin
papadimitriou2-Apr-08 3:24
papadimitriou2-Apr-08 3:24 
GeneralRe: Stupid question of the day (Trees) Pin
martin_hughes2-Apr-08 3:27
martin_hughes2-Apr-08 3:27 
GeneralRe: Stupid question of the day (Trees) Pin
ChrisKo2-Apr-08 5:41
ChrisKo2-Apr-08 5:41 
QuestionSimple question confused ! Pin
Krazy Programmer2-Apr-08 2:20
Krazy Programmer2-Apr-08 2:20 
GeneralRe: Simple question confused ! Pin
LongRange.Shooter2-Apr-08 4:01
LongRange.Shooter2-Apr-08 4:01 
GeneralRe: Simple question confused ! Pin
Krazy Programmer2-Apr-08 7:12
Krazy Programmer2-Apr-08 7:12 
GeneralMake a method return different types/classes depending on in-parameters Pin
arnold_w2-Apr-08 2:04
arnold_w2-Apr-08 2:04 
I want a method to return different types/classes depending on an in-parameter. More specifically, this is what I want to do:
public struct MyStruct
{
  public string myString;
  public byte myByte;
  public int myInt;

  // Constructor
  public MyStruct(
    string myString_,
    byte myByte_,
    int myInt_)
  {
    myString = myString_;
    myByte = myByte_;
    myInt = myInt_;
  }
}

public enum MyStructMemberSelector
{
  MY_STRING = 0,
  MY_BYTE,
  MY_INT
};

public MyStruct[] myStructArray = new MyStruct[]
{
  new MyStruct("String 1", (byte)1, 1),
  new MyStruct("String 2", (byte)2, 2)
};

// Returns the selected "column" in myStructArray as an array
public ? getAllItems(MyStructMemberSelector myStructMemberSelector)
{

  return ?;
}

.
.
.
  string[] myStringArray = getAllItems(MyStructMemberSelector.MY_STRING);
  byte[] myByteArray = getAllItems(MyStructMemberSelector.MY_BYTE);
  int[] myIntArray = getAllItems(MyStructMemberSelector.MY_INT);
.
.
.

How should I implement the getAllItems method? I am a beginner C#-programmer so please feel free to be specific and include snippets of code in your reply. Thanks in advance for any help!
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
papadimitriou2-Apr-08 3:34
papadimitriou2-Apr-08 3:34 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
Rob Philpott2-Apr-08 4:01
Rob Philpott2-Apr-08 4:01 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
arnold_w2-Apr-08 4:08
arnold_w2-Apr-08 4:08 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
Bekjong2-Apr-08 5:22
Bekjong2-Apr-08 5:22 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
led mike2-Apr-08 5:48
led mike2-Apr-08 5:48 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
Pete O'Hanlon2-Apr-08 10:13
mvePete O'Hanlon2-Apr-08 10:13 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
MidwestLimey2-Apr-08 11:38
professionalMidwestLimey2-Apr-08 11:38 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
Pete O'Hanlon2-Apr-08 22:32
mvePete O'Hanlon2-Apr-08 22:32 
GeneralRe: Make a method return different types/classes depending on in-parameters Pin
arnold_w3-Apr-08 1:17
arnold_w3-Apr-08 1:17 
GeneralC# HTTP request/response Pin
George_George2-Apr-08 2:02
George_George2-Apr-08 2:02 
GeneralCrystal reports how to suppress a section programmatically Pin
NewToAspDotNet2-Apr-08 1:49
NewToAspDotNet2-Apr-08 1:49 
QuestionHow to deserialize the object saved in project1 in another assembly project2? Pin
Chesnokov Yuriy2-Apr-08 1:41
professionalChesnokov Yuriy2-Apr-08 1:41 
GeneralRe: How to deserialize the object saved in project1 in another assembly project2? Pin
Simon P Stevens2-Apr-08 3:34
Simon P Stevens2-Apr-08 3:34 
GeneralRe: How to deserialize the object saved in project1 in another assembly project2? Pin
Giorgi Dalakishvili2-Apr-08 4:01
mentorGiorgi Dalakishvili2-Apr-08 4:01 
Generalproblem width Advantech PCI-1730 digital IO card [modified] Pin
arturw822-Apr-08 1:14
arturw822-Apr-08 1:14 
GeneralRe: problem width Advantech PCI-1730 digital IO card Pin
Dave Kreskowiak2-Apr-08 3:52
mveDave Kreskowiak2-Apr-08 3:52 
GeneralRe: problem width Advantech PCI-1730 digital IO card Pin
arturw822-Apr-08 4:13
arturw822-Apr-08 4:13 

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.