vb.net - How to construct single character constants -
how define constant char value, similar vbcr? not work...
public const ctrm char = "\m"c
this says constant must have 1 character. well, ok, isn't "\m" is?, following
public const ctrm char = convert.tochar(9)
that's not allowed because it's function. huh. luckily work:
public dim ctrm char = convert.tochar(9)
but seems sub-optimal. missing here?
the reply fsintegral fine, can simpler. , can utilize framework functions if prefer them vb functions.
class method:
public class appconsts public shared readonly ctrlem char = convert.tochar(25) public shared readonly ctrlt char = convert.tochar(9) public shared readonly ctrln char = convert.tochar(10) public shared readonly ctrlm char = convert.tochar(13) public shared readonly crlf string = ctrln & ctrlm ... end class 'usage: dim s string = "..." & appconts.ctrlem
they show in intellisense. if dont type/class name intruding, can import class (i kind of type portion included because narrows intellisense list rapidly relevant values):
imports appconsts .... dim s string = ctrlem
alternatively, can utilize module method:
module programme friend readonly ctrlm char = convert.tochar(25) end module ' usage: dim s2 string = "xxxx..." & ctrlm
they not constants far how compiler treats them @ compile time because aren't -- readonly fields. as far code concerned in ide, act, sense , taste constants.
it utilize of const
statement limits how can define them , require utilize (some) vb functions rather .net ones.
vb.net
No comments:
Post a Comment