如何在C#中的字符串变量上实现补码运算符(〜)? [英] How to implement one's complement operator (~) on a string variable in c#?

查看:120
本文介绍了如何在C#中的字符串变量上实现补码运算符(〜)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们!

我是这里的新手,也是C#语言的新手.我知道如何使用流读取器和写入器类从文件读取文本并将其写入.但是现在,我需要的是我必须在文本文件中加上一个文本作为补充.

我创建了一个带有文本框(多行)和一个按钮的Windows窗体应用程序,用于在文本框中提交文本.在按钮的onclick事件中,我编写了代码以打开文件("sample.txt"),并具有写许可权,并且文本直接进入文件,并在单击完成"按钮后被保存并关闭. br/>
很好,我想以加密格式将文本写入文件.在C语言中,我在变量上使用了〜"运算符以获取其补码形式.在C#中,我不知道该怎么做.我只想对要写入文件的字符串执行一个补码操作.我该怎么办?

预先感谢..

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..

推荐答案

这将帮助您获得答案 http://stackoverflow.com/questions/6528219/ones-complement [
This will help you get the answer http://stackoverflow.com/questions/6528219/ones-complement[^]


从文件中读取文本.获取单个字符及其ASCII值..稍后对此ASCII进行1的补码并转换为字符.
While reading text from file. Get individual characters and its ASCII value.. later do 1''s compliment for this ASCII and convert to character.


这篇关于如何在C#中的字符串变量上实现补码运算符(〜)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆