fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: X# equivalent of C# string cTest (One line syntax)

X# equivalent of C# string cTest (One line syntax) 1 year 1 month ago #4816

  ic2's Avatar Topic Author ic2 Offline Posts: 518
Wolfgang pointed me to a feature he called One line syntax, if I understood well, this is the equivalent of C#'s:

string cTest ="x"

directly within the code.
That seemed like a good idea to solve warnings XS103 e.g. in error handlers TRY/CATCH giving:
Warning CS0168 The variable 'e' is declared but never used

But I can't find this back in the help. I just defined a variable without declaring, this of course gives XS103 and the help says very promising " The following example resolves the error." except the sample box is empty...

How do I write string cTest ="x" in X#?

Dick

Please Log in or Create an account to join the conversation.

X# equivalent of C# string cTest (One line syntax) 1 year 1 month ago #4818

  SHirsch's Avatar SHirsch Offline Posts: 112
Hi Dick,

var cTest := "x"

or

LOCAL cTest := "x" AS STRING

Stefan

Please Log in or Create an account to join the conversation.

X# equivalent of C# string cTest (One line syntax) 1 year 1 month ago #4820

  ic2's Avatar Topic Author ic2 Offline Posts: 518
Hello Stefan,

That's quick!

Ok, it's that simple....

And indeed it works and is indeed very convenient.

I will paste a dozen of local cMessage:=e:Message as string or so which saves an equal number of warnings.

Dick

Please Log in or Create an account to join the conversation.

X# equivalent of C# string cTest (One line syntax) 1 year 1 month ago #4826

  Chris's Avatar Chris Offline Posts: 1220
Hi Dick,

In order to solve the problem with this exact issue, the compiler in the latest build supports a new syntax for CATCH:

CATCH AS Exception

(so no variable name). You can use this one to get rid of the warning, in places when you do not really need to use the Excaption variable (I know, there are plenty such situations).

hth,
Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

X# equivalent of C# string cTest (One line syntax) 1 year 1 month ago #4834

  ic2's Avatar Topic Author ic2 Offline Posts: 518
Hello Chris,

CATCH AS Exception



That's even better, in quite some situations!

Dick

Please Log in or Create an account to join the conversation.

  • Page:
  • 1