Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends!

I'm new here and to C# language. I know how to read text from files and write to them using stream reader and writer classes. But now, what I need is that I must write into text files with the text one's complemented.

I've created a windows form application with a textbox(multiline) and a button to submit the text in the textbox. In the onclick event of the button, I've written code to open the file("sample.txt") with write permissions and the text directly goes into the file and is saved and closed on clicking the "done" button.

This is fine and I want to write the text into the file in encrypted format. In c language, I've used the " ~ " operator on a variable to get it's one's complemented form. In c# i don't know how to do this. I just want to perform the one's complement operation on the string to be written to a file. How can I do this??

Thanks in advance..
Posted

 
Share this answer
 
While reading text from file. Get individual characters and its ASCII value.. later do 1's compliment for this ASCII and convert to character.
 
Share this answer
 
Comments
Prashanth Sn 9-Sep-12 0:51am    
how do I get the ASCII values for the characters???
Please elaborate and explain i'm new to this language..
Suraj S Koneri 9-Sep-12 0:55am    
Once you get char of each characters in string. Convert that char to integer then perform you one's compliment.

After getting result again put it as char later to string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900