| View previous topic :: View next topic |
| Author |
Message |
KryziK Expert Cheater
Reputation: 3
Joined: 16 Aug 2009 Posts: 199
|
Posted: Mon Jan 24, 2011 6:46 pm Post subject: [C#] Function Parameters |
|
|
My question is: If I have a function, DoStuff(byte[] bInput),
can I somehow call it without previously declaring bInput? Something like:
DoStuff({0xAA, 0xBB, 0xCC})
rather than
byte[] bInput = {0xAA, 0xBB, 0xCC}
DoStuff(bInput)
Hopefully my question was clear enough, and thanks in advance, regardless of the answer.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Jan 24, 2011 7:50 pm Post subject: |
|
|
You should be able to call it like:
| Code: | | DoStuff( new byte[] { 0xAA, 0xBB, 0xCC } ); |
_________________
- Retired. |
|
| Back to top |
|
 |
KryziK Expert Cheater
Reputation: 3
Joined: 16 Aug 2009 Posts: 199
|
Posted: Mon Jan 24, 2011 7:53 pm Post subject: |
|
|
| Oh, wow. I tried that before and it didn't work. Works now, thanks a bunch!
|
|
| Back to top |
|
 |
AhMunRa Grandmaster Cheater Supreme
Reputation: 27
Joined: 06 Aug 2010 Posts: 1117
|
Posted: Mon Jan 24, 2011 7:54 pm Post subject: |
|
|
For something like that with only the one arg you could do
DoStuff(parameters byte[] bInput)
{
psuedo mystuff;
}
DoStuff(1,2,3,4,5,6);
is the same as
byte[] bInput = {1, 2, 3, 4, 5, 6};
DoStuff(bInput);
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.> |
|
| Back to top |
|
 |
KryziK Expert Cheater
Reputation: 3
Joined: 16 Aug 2009 Posts: 199
|
Posted: Mon Jan 24, 2011 7:58 pm Post subject: |
|
|
| Thanks for the tip! Unfortunately none of them are only one parameter, but I'll keep it in mind for later use.
|
|
| Back to top |
|
 |
AhMunRa Grandmaster Cheater Supreme
Reputation: 27
Joined: 06 Aug 2010 Posts: 1117
|
Posted: Mon Jan 24, 2011 8:08 pm Post subject: |
|
|
I think Wiccans is closest to one param.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.> |
|
| Back to top |
|
 |
KryziK Expert Cheater
Reputation: 3
Joined: 16 Aug 2009 Posts: 199
|
Posted: Thu Jan 27, 2011 9:52 pm Post subject: |
|
|
Wiccan's reply is exactly what I needed.
| Quote: | | Works now, thanks a bunch! |
|
|
| Back to top |
|
 |
|