Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#] Function Parameters

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Mon Jan 24, 2011 6:46 pm    Post subject: [C#] Function Parameters Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Jan 24, 2011 7:50 pm    Post subject: Reply with quote

You should be able to call it like:
Code:
DoStuff( new byte[] { 0xAA, 0xBB, 0xCC } );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Mon Jan 24, 2011 7:53 pm    Post subject: Reply with quote

Oh, wow. I tried that before and it didn't work. Works now, thanks a bunch!
Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Mon Jan 24, 2011 7:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Mon Jan 24, 2011 7:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Mon Jan 24, 2011 8:08 pm    Post subject: Reply with quote

I think Wiccans is closest to one param.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
KryziK
Expert Cheater
Reputation: 3

Joined: 16 Aug 2009
Posts: 199

PostPosted: Thu Jan 27, 2011 9:52 pm    Post subject: Reply with quote

Wiccan's reply is exactly what I needed.
Quote:
Works now, thanks a bunch!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites