Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I just started C#.
I can't seem to find a way of the program closing it if the, if else, equals no.
I've tried :
-> System.Environment.Exit(1);
-> public static void Exit ();
A part of the Code:
Console.WriteLine("Jes/No");
string input = Console.ReadLine();
if (input == "Jes")
{
Console.WriteLine("Welcome to the Apex Libary");
}
if (input == "No")
{
________________________
}
The Blanks :______________ , are a space holder so that I know where to put the code.
Use :
Environment.Exit(0);
This command is used to close the application by providing an exit code.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
The c# standard library currently has a Char.IsSymbol Method here.
Does anyone have any suggestions how I could implement a Char.IsCurrencySymbol method?
Char.IsCurrencySymbol('$')
// true
Char.IsCurrencySymbol('#')
//false
Like this:
public static class Extensions
{
public static bool IsCurrencySymbol(this char c)
{
return char.GetUnicodeCategory(c) == UnicodeCategory.CurrencySymbol;
}
}
Usage:
bool yes = '$'.IsCurrencySymbol();
bool no = '#'.IsCurrencySymbol();
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
As mentioned in title, I'm basically developing a program (Server/client)
where the server inserts some data in a table row, and the client is reading the data.
while (true)
{
string Command = ReadData();
//Read row
if (Command != string.Empty)
{
switch(Command)
{
case "Connection":
Console.writeLine("Connected !");
break;
}
}
else
{
console.writeLine("No data were found ! ");
}
}
The Readata();function only returns a string if found in a row.
The default Data in that Row is Null - there is no stored data in that row until the server inserts some information like a Command on it.
The Client will always read that row and for each time it finds something other than null it will execute some code.
Won't that break the program while executed?
I hope my question is clear, and have a nice day!
It won't break the program if the client appropriately handles the case where the row doesn't exist.
For example (pseudo code)
loop {
checkForRow();
if (row.exists) {
readRowData();
clearRowData();
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make background code that checks if someone hit "H","D", or other letters. Like This,(I mean a background code that is checking this.)
if(e.KeyCode == Keys.U)
{
code;
}
In WinForms you can override onKeyDown() like so:
protected override void onKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.YourKey)
{
// Do something
}
}
Where you substitute YourKey with desired key from Keyboard. (You can use intellisense to see all available options)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I usually never use char so sorry if it seems a noob question. I'm doing a Crypter, and wanted to do "if there's at least 4 differents char, then crypt, else don't crypt and return error"
Actual Code:
string msg = Console.ReadLine();
char[] msgToChar = msg.ToCharArray();
if(here is the problem)
{
Console.WriteLine("Crypted message: " + Crypt(msg.ToUpper()));
}
else
{
Console.WriteLine("Please enter at least 4 differentes characters.");
}
You could do this to get the distinct count of characters.
msgToChar.Distinct().Count()
So your if would be something like
if (msgToChar.Distinct().Count() >= 4)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have made replace function, but I am really struggling to make "Replace All"
function.
I tried to make into for loop but that didn't work well...
I have dialog box just like in usual Notepad (another form) and i have richtextbox in Main form. Any ideas how can I make it?
You can simply use the String.Replace method:
private void DoReplace(string SearchFor, string ReplaceWith)
{
RichTextBox1.Text = RichTextBox1.Text.Replace(SearchFor, ReplaceWith);
}
Call this function and supply the string you want to search for in Richtextbox1 (or whatever it is called in your case) as the first parameter and the replacement as the second parameter.