using System; using System.Globalization; public class NumParsingApp { public static void Main(string[] args) { CultureInfo dk = new CultureInfo("da-DK"); int k = 12345; string w = k.ToString("c", dk); Console.WriteLine(w); } }
Author: coder
Use CultureAndRegionInfoBuilder
using System; using System.Collections.Generic; using System.Text; using System.Globalization; class Program { static void Main(string[] args) { CultureAndRegionInfoBuilder styria = new CultureAndRegionInfoBuilder( "de-AT-ST", CultureAndRegionModifiers.None); styria.LoadDataFromCultureInfo(new CultureInfo("de-AT")); styria.LoadDataFromRegionInfo(new RegionInfo("AT")); styria.Register(); } }
X, F1, Z, Escape key from ConsoleKey
using System;
using System.Collections.Generic;
class MainClass
{
public static void Main()
{
ConsoleKeyInfo key;
List
do{
key = Console.ReadKey(true);
if (key.Key == ConsoleKey.F1)
{
Console.WriteLine(“F1”);
}
if (key.Key == ConsoleKey.Backspace)
{
if (input.Count > 0)
{
input.RemoveAt(input.Count – 1);
Console.Write(key.KeyChar);
}
}else if (key.Key == ConsoleKey.Escape){
Console.Clear();
Console.WriteLine(“Input: {0}
“,new String(input.ToArray()));
input.Clear();
}else if (key.Key >= ConsoleKey.A && key.Key <= ConsoleKey.Z){
input.Add(key.KeyChar);
Console.Write(key.KeyChar);
}
} while (key.Key != ConsoleKey.X || key.Modifiers != ConsoleModifiers.Alt);
}
}
[/csharp]
Beep(200, 300)
using System; using System.Media; class MainClass { public static void Main() { // Play a beep with frequency as 200 and duration as 300 Console.Beep(200, 300); } }
Beep
using System; using System.Media; class MainClass { public static void Main() { Console.Beep(); } }
Use Red and Green from ConsoleColor
using System; public class MainClass { static void Main(string[] args) { // Change the console appearance and redisplay. Console.Title = "Colored Text"; Console.ForegroundColor = ConsoleColor.Red; Console.BackgroundColor = ConsoleColor.Green; } }
CursorVisible ResetColor SetWindowSize BufferHeight BufferWidth CursorLeft CursorSize CursorTop
using System; public class MainClass { static void Main(string[] args) { // Change the console appearance and redisplay. Console.Title = "Resized Console"; Console.ResetColor(); Console.Clear(); Console.SetWindowSize(100, 50); Console.BufferHeight = 500; Console.BufferWidth = 100; Console.CursorLeft = 20; Console.CursorSize = 50; Console.CursorTop = 20; Console.CursorVisible = false; } }