JDYoder Posted August 9, 2005 Posted August 9, 2005 What is considered the .NET replacement of the above? Quote
Joe Mamma Posted August 9, 2005 Posted August 9, 2005 System.Environment.NewLine Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
JDYoder Posted August 11, 2005 Author Posted August 11, 2005 How about the replacement for vbTab? Quote
*Experts* Bucky Posted August 11, 2005 *Experts* Posted August 11, 2005 You could use ControlChars.Tab, but the ControlChars class is VB-specific and I wouldn't reccomend it. You can also use Convert.ToChar(9), since 9 is the Unicode value for a tab character. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Joe Mamma Posted August 11, 2005 Posted August 11, 2005 (edited) As I can never remember the codes for keys, I like - (char) Keys.Tab or in either this will work, too: Convert.ToChar(Keys.Tab) Too bad "Keys.Tab.ToString()" doesn't return the tab character, eh? hmmmm. . . . give me a moment. . . . Edited August 11, 2005 by Joe Mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted August 11, 2005 Posted August 11, 2005 (edited) probably easier to do with CodeDom, but I have never used it. . . to generate a class with usage: char c = Unicode.Chars.Tab; string c = Unicode.Chars.Tab.ToString(); executing this line: Unicode.GenClass.Chars.GenClass(); on this class: using System; namespace Unicode.GenClass { public sealed class Chars { private Chars() {} static void EnumProperty(string aKey) { object testKey = Enum.Parse(typeof(System.Windows.Forms.Keys), aKey); if ( (Convert.ToInt32(testKey)> UInt16.MaxValue) | Convert.ToInt32(testKey) < 0) return; Console.WriteLine(""); string keyName = aKey; string keytype = string.Format("System.Windows.Forms.Keys.{0}", keyName); Console.WriteLine(string.Format("\t\tstatic public char {0}", keyName)); Console.WriteLine("\t\t{"); Console.WriteLine("\t\t\tget"); Console.WriteLine("\t\t\t{"); Console.WriteLine(string.Format("\t\t\t\t return(char){0};", keytype)); Console.WriteLine("\t\t\t}"); Console.WriteLine("\t\t}"); } public static void GenClass() { Console.WriteLine("using System;"); Console.WriteLine(""); Console.WriteLine("namespace Unicode"); Console.WriteLine("{"); Console.WriteLine("\tpublic sealed class Chars"); Console.WriteLine("\t{"); Console.WriteLine(""); Console.WriteLine("\t\tprivate Chars(){}"); foreach (string akey in Enum.GetNames(typeof(System.Windows.Forms.Keys))) EnumProperty(akey); Console.WriteLine("\t}"); Console.WriteLine("}"); } } } [/CS] genrated the attached source to the console windowUnicode.Chars.zip Edited August 11, 2005 by Joe Mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted August 11, 2005 Posted August 11, 2005 I am sure the above would be easier and more elegant with CodeDOM, but I have never played with it. . . Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted August 11, 2005 Posted August 11, 2005 the first handful of properties generated as the code is too long to post. . . using System; namespace Unicode { public sealed class Chars { private Chars(){} static public char None { get { return(char)System.Windows.Forms.Keys.None; } } static public char LButton { get { return(char)System.Windows.Forms.Keys.LButton; } } static public char RButton { get { return(char)System.Windows.Forms.Keys.RButton; } } static public char Cancel { get { return(char)System.Windows.Forms.Keys.Cancel; } } static public char MButton { get { return(char)System.Windows.Forms.Keys.MButton; } } static public char XButton1 { get { return(char)System.Windows.Forms.Keys.XButton1; } } static public char XButton2 { get { return(char)System.Windows.Forms.Keys.XButton2; } } static public char Back { get { return(char)System.Windows.Forms.Keys.Back; } } static public char Tab { get { return(char)System.Windows.Forms.Keys.Tab; } } static public char LineFeed { get { return(char)System.Windows.Forms.Keys.LineFeed; } } static public char Clear { get { return(char)System.Windows.Forms.Keys.Clear; } } static public char Return { get { return(char)System.Windows.Forms.Keys.Return; } } static public char Enter { get { return(char)System.Windows.Forms.Keys.Enter; } } static public char ShiftKey { get { return(char)System.Windows.Forms.Keys.ShiftKey; } } static public char ControlKey { get { return(char)System.Windows.Forms.Keys.ControlKey; } } static public char Menu { get { return(char)System.Windows.Forms.Keys.Menu; } } static public char Pause { get { return(char)System.Windows.Forms.Keys.Pause; } } static public char CapsLock { get { return(char)System.Windows.Forms.Keys.CapsLock; } } Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
*Experts* Nerseus Posted August 12, 2005 *Experts* Posted August 12, 2005 If everyone in your group agrees to it, you can just use "\t", as Joe sorta had embedded in one of his samples. I'd only do that if everyone knows and understands what \t is - if your group thinks that's too obscure, then don't use it. I often use \n in strings for newline if they're embedded. I'll use Environment.NewLine for piecing strings together. For example: string s = "You are about to delete your whole Database and format the hard drive.\n\nAre you sure?" string s2 = "Bob" + Environment.NewLine; s2 += "The" + Environment.NewLine; s2 += "Builder"; Of course, I'd probably use StringBuilder in place of s2, but I don't want to type that out right now... -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
JDYoder Posted August 12, 2005 Author Posted August 12, 2005 We're using VB.NET, so \t and \n aren't an option, but thanks anyway. Quote
JDYoder Posted August 16, 2005 Author Posted August 16, 2005 In working with something different, I came across the "ControlChars" object in the helpfile. If you type it and hit "." you'll find methods such as... ControlChars.NewLine ControlChars.CrLf ControlChars.Tab Along with a few others. (The first two above are the same thing.) Not sure if they are more or less preferred over System.Environment.NewLine, but thought I'd pass it on if others are interested at least in the .Tab, which I think is handy. Quote
JDYoder Posted August 16, 2005 Author Posted August 16, 2005 Ah, crud. Just figured out that ControlChars is a part of MS.VB. Never mind. :p Quote
mandelbrot Posted August 16, 2005 Posted August 16, 2005 Just out of interest, here, are we talking VS.NET or ASP.NET? I've just tried vbCrLf and it does convert... Is this a good practice/bad practice thing? There seem to be so many of them... Paul. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.