[英]How can I prevent the `private` access modifier from being added in VS Code for C# when generating members?
[英]c# how do i prevent one specific character from being added to a text file
我有一個程序,用戶在其中將數據輸入文本框,然后按下一個按鈕,使用 stream writer 將其添加到文本文件中。 如何在用戶嘗試輸入字符“~”時出現錯誤。 它破壞了整個程序,因為它用於分隔文本文件中的不同數據。
檢查用戶輸入字符串是否包含您要禁止的字符。 像下面一樣,
string userInput= myTextBox.Text;
if( userInput.Contains('~') )
MessageBox.Show("This ~ char is not allowed");
...
//write to file
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.