Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια
σε

 

Αρχική σελίδα Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες

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

Όλες οι Ετικέτε... » C# » Posts   (RSS)
  • HowTo: Use latest C# features in MVC5 Razor views (.cshtml)

    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 […]
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Απριλίου 16, 2019
  • Gotcha: use parentheses around ternary op conditional expressions

    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? ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Αυγούστου 25, 2018
  • Nested LINQ Aggregate queries vs Nested Foreach statements example

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Μαΐου 29, 2016
  • Suggestion: add optional “where” clause to “foreach” statement in C#

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Μαΐου 16, 2016
  • Suggestion: Add instance modifiers to C# (and other languages)

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Μαΐου 11, 2016
  • Suggestion: If and while etc. clauses should accept bool? in C#

    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) ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Δεκεμβρίου 10, 2015
  • HowTo: show inner exception message if available, else outer one

    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 […]
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Δεκεμβρίου 9, 2015
  • Suggestion: C# static extension methods invokable on class type too

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Δεκεμβρίου 9, 2015
  • Suggestion: Initialize multiple fields to same value at constructor call in C#

    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, ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Νοεμβρίου 30, 2015
  • Suggestion: on Duck Typing and C#/.NET

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Νοεμβρίου 16, 2015
  • Suggestion: Add support for constants in C# (and VB.net etc.) interfaces

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Νοεμβρίου 16, 2015
  • Suggestion: Introduce .= operator for C#

    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, ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Νοεμβρίου 11, 2015
  • Suggestion: Define once and reuse result type of method inside its body

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Νοεμβρίου 10, 2015
  • Suggestion: Allow local nested methods inside any code block

    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 […]
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Σεπτεμβρίου 5, 2015
  • Suggestion: Define scoped variable at C# switch conditional statement

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Σεπτεμβρίου 1, 2015
  • Suggestion: property and event setting block attached to C# type instance

    Instead of having to write in C#       speechRecognizer = CreateSpeechRecognizer();       if (speechRecognizer != null)       {         speechRecognizer.SomeProperty = someValue;         ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Αυγούστου 25, 2015
  • Suggestion: implement ignore keyword or allow missing catch block in C#

    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 […]
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Αυγούστου 23, 2015
  • Suggestion: Allow new in C# without giving Type

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Αυγούστου 23, 2015
  • Gotcha: no prefix increment/decrement VB.net operators, but get parsed

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Αυγούστου 9, 2014
  • C# Using Alias Directive, Namespace Alias Qualifier and a sad story

    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 ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Ιουλίου 4, 2012
  • Why I don’t see static extension support for constructors in C# coming

    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 : ...
    Δημοσιεύτηκε στο George Birbilis' blog (Weblog) από το μέλος birbilis στις Ιουλίου 2, 2012
Με χρήση του Community Server (Commercial Edition), από την Telligent Systems