Παρουσίαση με Ετικέτες

HowTo: Use latest C# features in MVC5 Razor views (.cshtml)
16 Απριλίου 19 03:53 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Having recently updated an ASP.net MVC web app from MVC4 to MVC5 and from .NET 4.5 to .NET 4.7.2 I was expecting Razor views (.cshtml files) to use the latest C# compiler, especially since at Properties/Build/Advanced option for the web project one read “C# latest major version (default)”. However that was not the case and […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Gotcha: use parentheses around ternary op conditional expressions
25 Αυγούστου 18 03:42 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Just came across the following case in C# that puzzled me momentarily, especially since the strings involved were long enough and the expression was broken on multiple lines: bool flag = true; string test1 = flag? "xa" : "xb"; string test2 = "x" + (flag? "a" : "b"); string test3 = "x" + flag? "a" […]
Δημοσίευση στην κατηγορία: , , , , , , , ,
Nested LINQ Aggregate queries vs Nested Foreach statements example
29 Μαΐου 16 02:55 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
At Trafilm project’s Metadata (http://github.com/zoomicon/Trafilm.Metadata) I have a linked data structure where a Film contains multiple Conversations which contain multiple L3SToccurrences, which in turn contain multiple L3TToccurrences. I had the need to calculate a list of all unique L2language values of L3TToccurrence grand-grand-children for a Film (to keep as calculated metadata for display at the […]
Δημοσίευση στην κατηγορία: , , , , , , , , , ,
Suggestion: add optional “where” clause to “foreach” statement in C#
16 Μαΐου 16 11:33 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Wouldn’t it be nice if I could use in C# the following syntax? for (SomeType repeaterVariable       in SomeEnumerable       where someBooleanExpressionOfRepeaterVariable)   doSomethingUsingRepeaterVariable; e.g. use this one: instead of this one: BTW, if you wonder what FixTime does, it prepends 0: to time strings to make sure they are of format h:m:s.f Have added […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: Add instance modifiers to C# (and other languages)
11 Μαΐου 16 12:48 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
I’d like to be able to do someFunctionReturningY(x){ somePropertyOfY=4; … }.DoSomething(); It should also support casting without needing parentheses in the following type of statement: Z zzz = (Z)functionReturningY{somePropertyOfZ=…; … };   The same pattern should work for enums too apart from object instances. It is inspired by initializers in C#, e.g. var x = […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Suggestion: If and while etc. clauses should accept bool? in C#
10 Δεκεμβρίου 15 04:33 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
At TrackingCam app (http://TrackingCam.codeplex.com) I have the following WPF code, where cbTrackingPresenter is a CheckBox control defined in my MainWindow’s XAML: private void cbTrackingPresenter_Checked(object sender, RoutedEventArgs e) {       if (cbTrackingPresenter.IsChecked == true)           StartTrackingPresenter();       else           StopTrackingPresenter(); } Note the (redundant in my opinion) == true pattern used there. If the == true […]
Δημοσίευση στην κατηγορία: , , , , , ,
HowTo: show inner exception message if available, else outer one
09 Δεκεμβρίου 15 05:44 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Sometimes when you catch an exception in .NET, the message it prints out isn’t very informative, since it is wrapping another exception that had been thrown a bit inner in the code. That exception is in that case accessible via InnerException of the Exception instance. That inner exception is also an Exception, so one would […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: C# static extension methods invokable on class type too
09 Δεκεμβρίου 15 05:30 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
it would be nice if C# supported syntax like: public static DependencyProperty Register(static DependencyProperty x, string name, Type propertyType, Type ownerType, FrameworkPropertyMetadata typeMetadata) that is static extension methods for classes, that can be invoked without a class instance (just with the class type), apart from normal extension methods that can be invoked on a class […]
Δημοσίευση στην κατηγορία: , , , , , , , ,
Suggestion: Initialize multiple fields to same value at constructor call in C#
30 Νοεμβρίου 15 12:45 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
When using http://github.com/zoomicon/ZUI I would like to write: FloatingWindow window = new FloatingWindow() {   Content = display,   Title = IconText = title }; but I have to write: FloatingWindow window = new FloatingWindow() {   Content = display,   Title = title,   IconText = title }; instead. For consistency, I’d prefer that […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: on Duck Typing and C#/.NET
16 Νοεμβρίου 15 03:32 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
My comment at: http://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/4272089-support-implicit-interfaces-for-code-reuse It would be nice indeed if one could define at the client object’s side a static interface that is a subset of the methods of a server (or serving if you prefer) object (it is only the view of the server that the client has gained knowledge of) that has been […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Suggestion: Add support for constants in C# (and VB.net etc.) interfaces
16 Νοεμβρίου 15 12:52 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
It is rather unfortunate that C# doesn’t support constants in interfaces, whereas Java does. If IL (intermediate language) that C# usually compiles to (when not using AOT that is like in .NET Native or Xamarin iOS) doesn’t support this, then the compiler could create a special sealed class to carry the constants. Then, wherever they’re […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Suggestion: Introduce .= operator for C#
11 Νοεμβρίου 15 05:45 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
It would be nice if one could write in C# (and maybe in other .NET languages too): s = s.SomeMethodOfS(…)… as s .= SomeMethodOfS(…)… that is to have a .= operator, similar to += and other shorthand experession operators see screenshot for an example usecase from the opensource project FoscamController     Ideally, usage of […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: Define once and reuse result type of method inside its body
10 Νοεμβρίου 15 11:58 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
It would be nice if one could rewrite this C# snippet: public SortedDictionary<string, UObject> GetObjects() {   SortedDictionary<string, UObject> result = new SortedDictionary<string, UObject>();   using (ReadTransaction xact = namingSchema.ReadTransaction())     foreach (ObjectName.RowType row in ObjectName.object_name_(xact))       result.Add(row.name_, row.object_);   return result; }   in a more concise form like:   public T GetObjects() where T=SortedDictionary<string, UObject> {   T result […]
Δημοσίευση στην κατηγορία: , , , , , , , , ,
Suggestion: Allow local nested methods inside any code block
05 Σεπτεμβρίου 15 09:44 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
It would be nice if one could define methods inside other methods so that they are only accessible in the context of the parent method. In Pascal one could define them at the start of the parent method, before any other commands, but after local variables block, so they could also access the variables of […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Suggestion: Define scoped variable at C# switch conditional statement
01 Σεπτεμβρίου 15 08:47 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Trying to reuse the conditional value of a switch statment in C# at the fallback “default” code block of it, and looking up if that was supported in C#, I found the a related discussion at: http://stackoverflow.com/questions/29628507/c-sharp-get-switch-value-if-in-default-case I added a comment there and also elaborated it a bit more at a suggestion (PLEASE VOTE IT […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: property and event setting block attached to C# type instance
25 Αυγούστου 15 03:31 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Instead of having to write in C#       speechRecognizer = CreateSpeechRecognizer();       if (speechRecognizer != null)       {         speechRecognizer.SomeProperty = someValue;         speechRecognizer.SomeOtherProperty = someOtherValue;         speechRecognizer.SpeechRecognized += SpeechRecognized;         speechRecognizer.SpeechHypothesized += SpeechHypothesized;         speechRecognizer.SpeechRecognitionRejected += SpeechRecognitionRejected;       } I’d prefer to write:       speechRecognizer = CreateSpeechRecognizer() {         SomeProperty = someValue,         SomeOtherProperty […]
Δημοσίευση στην κατηγορία: , , , , , ,
Suggestion: implement ignore keyword or allow missing catch block in C#
23 Αυγούστου 15 01:23 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
This is a suggestion I’ve just sent in via Visual Studio’s “Send a frown” feature (rewritten here a bit differently from memory, since that feedback channel doesn’t allow you to access your previous feedback as the Microsoft Connect or the Uservoice site does) : Instead of having to write try {   … } catch […]
Δημοσίευση στην κατηγορία: , , , , , , ,
Suggestion: Allow new in C# without giving Type
23 Αυγούστου 15 01:12 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
This is a suggestion I’ve just sent in via Visual Studio’s “Send a frown” feature: Instead of writing statements like:   List<CultureInfo> result = new List<CultureInfo>(); in C# I’d prefer to be able to write   List<CultureInfo> result = new (); inside the () one would be able to pass contructor parameters and also they […]
Δημοσίευση στην κατηγορία: , , , , ,
Gotcha: no prefix increment/decrement VB.net operators, but get parsed
09 Αυγούστου 14 03:39 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
In C/C++ and C# one has useful prefix (++index) and postfix (index++) increment operators and corresponding decrement ones. Although they have a single operant, they’re not working like functions as single + or – prefix would do, but instead they cause side-effects – they edit the variable passed to them. The prefix increment operator first […]
Δημοσίευση στην κατηγορία: , , , , , , , , ,
C# Using Alias Directive, Namespace Alias Qualifier and a sad story
04 Ιουλίου 12 10:45 μμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
Following up on my last post: http://zoomicon.wordpress.com/2012/07/04/how-to-compile-code-that-uses-wpf-decorator-type-in-silverlight/ I’m copying from a mental note I added to: http://stackoverflow.com/questions/4936941/using-a-using-alias-class-with-generic-types/11334359: As shown at: http://msdn.microsoft.com/en-us/library/sf0df423.aspx and http://msdn.microsoft.com/en-us/library/c3ay4x3d%28VS.80%29.aspx you can do: using gen = System.Collections.Generic; using GenList = System.Collections.Generic.List<int>; and then use gen::List<int> x = new gen::List<int>; or GenList x = new GenList(); However: you have to replicate those using [...]
Δημοσίευση στην κατηγορία: , , , , , , , ,
Why I don’t see static extension support for constructors in C# coming
02 Ιουλίου 12 12:30 πμ | Μπιρμπίλης Γεώργιος | 0 σχόλια   
I was hoping C# would someday add static extension support for constructors too (apart from classic methods), that would help a lot in source-level compatibility layers (for example at my WPF_Compatibility project for WPF syntax in Silverlight, which one can find under the ClipFlair source base). However, according to : http://mrpmorris.blogspot.gr/​2007/01/​net-calling-base-constructors-i​n-c.html Anders Hejlsberg (father of [...]
Δημοσίευση στην κατηγορία: , , , , , , ,

Search

Go

Ιστορικό Δημοσιεύσεων

Συνδρομές