Yes but I can't do this... in C# like I can in Typescript
namespace myClassAndFunctionLibrary { public Func<string> junk=()=>"junk"; public Class MyClass{ } }
Sure, but my point is you are not missing anything in terms of capability.
namespace MyLibrary { public static class J { public static Func<string> unk = () => "junk"; } }
There. Now you can access it via J.unk. Happy? I mean, what is it you really want? You're gonna need to find far worse things to leverage any kind of meaningful criticism against C# here.
J.unk
Or here's one...
namespace MyLibrary { public static class func { public static Func<string> junk = () => "junk"; public static Func<string,string> append = (item)=> item + "appended"; public static string append2(this string input){ return input + "appended"; } } } //elsewhere var junk = func.Junk(); var appended = func.append("prefix"); var appended2 = "prefix".append2();
The C# Equivalent of first class functions in Typescript/JavaScript are Extension Methods.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes but I can't do this... in C# like I can in Typescript
Sure, but my point is you are not missing anything in terms of capability.
There. Now you can access it via
J.unk
. Happy? I mean, what is it you really want? You're gonna need to find far worse things to leverage any kind of meaningful criticism against C# here.Or here's one...
The C# Equivalent of first class functions in Typescript/JavaScript are Extension Methods.