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# String And Byte Array Problem

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

Joined: 19 Jul 2015
Posts: 154

PostPosted: Wed Dec 07, 2016 10:31 am    Post subject: C# String And Byte Array Problem Reply with quote

Hey guys.

1) I want to Initialize a string variable with the value :

" {"gamesHistory":"{\"18427757055\":[{\"userName\":\"hask\",\"winner\":true,\"userID\":\"291\"},{\"userName\":\"nae\",\"winner\":false,\"userID\":\"928\"} "


2) I want to use byte in for loop and concatenate in between of a byte array for example:

for(byte k = 0;k<100;k++)
{
byte[] lol = {0x00,0x23,0x81} // here I want to replace 23 with the value of k
}

Thanks In Advance
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Dec 07, 2016 2:05 pm    Post subject: Reply with quote

I can only assume you actually wanted:
Code:
string myvar = " {\"gamesHistory\":{\"18427757055\":[{\"userName\":\"hask\",\"winner\":true,\"userID\":\"291\"},{\"userName\":\"nae\",\"winner\":false,\"userID\":\"928\"}]}} "


https://msdn.microsoft.com/en-us/library/system.buffer.blockcopy(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp
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: Wed Dec 07, 2016 3:14 pm    Post subject: Reply with quote

1. As Zanzer showed, you need to escape the double-quotes that are not containing the string and are part of the string via \".

2. You haven't really given that great of an explanation. Your description and your comment in the code contradict themselves.

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

Joined: 19 Jul 2015
Posts: 154

PostPosted: Wed Dec 07, 2016 8:14 pm    Post subject: Reply with quote

Thank guys for your answers...

1) Actually the problem is \" is a part of string and Compiler is taking it as a escape sequence...


2) leave this problem for now I think I will not need this if 1st is solved


Thanks In Advance
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Dec 07, 2016 11:24 pm    Post subject: Reply with quote

Code:
string myvar = @" {\""gamesHistory\"":{\""18427757055\"":[{\""userName\"":\""hask\"",\""winner\"":true,\""userID\"":\""291\""},{\""userName\"":\""nae\"",\""winner\"":false,\""userID\"":\""928\""}]}} "

Code:
string myvar = " {\\\"gamesHistory\\\":{\\\"18427757055\\\":[{\\\"userName\\\":\\\"hask\\\",\\\"winner\\\":true,\\\"userID\\\":\\\"291\\\"},{\\\"userName\\\":\\\"nae\\\",\\\"winner\\\":false,\\\"userID\\\":\\\"928\\\"}]}} "
Back to top
View user's profile Send private message
lolAnonymous
Expert Cheater
Reputation: 1

Joined: 19 Jul 2015
Posts: 154

PostPosted: Thu Dec 08, 2016 12:50 am    Post subject: Reply with quote

Thanks Zanzer your answer solved the problem.. Very Happy


Thanks Zanzer and aom0s for both of your time Smile
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Dec 08, 2016 6:18 pm    Post subject: Reply with quote

By the way, string literals and escape characters are something you learn about on day one.
You really ought to watch some introductory course on C# before jumping into trainers.
Help for you might be running out if you continue with questions like these.
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