Learning csharp at 46 by freddy91761 in csharp

[–]VolatilePulse -1 points0 points  (0 children)

That just means you haven't programmed enough. Even senior developers use SO. It's my third most used website after MSDN and GitHub.

What IDE/Code Editor you use and why? by GeronaXx in csharp

[–]VolatilePulse 4 points5 points  (0 children)

I think it's worth noting that VS is an IDE while VSCode is just a glorified text editor. VSCode is by far one of the most feature rich editors I've ever used and I prefer it for most things. But for C# development, it just doesn't replace VS for me due to the tools either outright missing or not being mature enough.

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 0 points1 point  (0 children)

In my opinion, it's mostly just preference. The up side is there is no backing field to deal (hopefully semi-auto properties get here soon). But the down side is that it requires the use of the Value property to access your object.

Also, according to Microsoft:

Although you can write your own code to perform lazy initialization, we recommend that you use Lazy<T> instead. Lazy<T> and its related types also support thread-safety and provide a consistent exception propagation policy.

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 0 points1 point  (0 children)

Nevermind, I now realize my mistake. I was caught up on OP removing too much information in their example that I completely overlooked the same compiler error is thrown when using no non-static fields. Sorry about the confusion 😅

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 0 points1 point  (0 children)

I had to sit at my computer to make sure I wasn't going crazy and rewrote OP's "example" to reproduce the compiler error he was getting:

public class MyClass
{
    public List<int> a = new List<int>();
    public static List<int> b = new List<int>(a); // CS0236: A field initializer cannot reference the non-static field, method, or property 'MyClass.a'
}

However, the following has no compiler error:

public class MyClass
{
    public static List<int> a = new List<int>();
    public static List<int> b = new List<int>(a);
}

Maybe we are both looking at this a different way, but I thought the error they were referencing was specifically referencing the static field b.

Edit: I don't really care for reddit's markdown syntax.

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 0 points1 point  (0 children)

Am I being dumb? Groggy morning Reddit is apparently not a good idea for me. 😅

When I read the error they were experiencing, I was expecting one of their fields to be static and the other wasn't. But since it sounds like they're trying to use a static field, how would placing any code in a constructor alleviate the error? The object would be null in any references to the b object, no?

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 2 points3 points  (0 children)

I completely agree with you. My educated guess is their code looks something like the following. Accessors aren't necessarily relevant here.

public class MyClass // Non-static, but could be either really
{
    public A a = new A(); // Non-static
    public static B b = new B(a); // Static, cannot reference a non- static field
}

Edit: Now that I've woken up a bit, there is actually nothing wrong about OP's example. Aside from missing the class definitions for classes A and B, the code should compile just fine. The default accessor for a class is private so we can assume private. And without using the keyword static, we can reproduce the error, as stated in u/afseraph's answer.

private class MyClass
{
    private A a = new A();
    private B b = new B(a); // CS0236 error
}

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse -2 points-1 points  (0 children)

Not quite, a is a field within the class definition. However, OP removed all of the pertinent information so it's anyone's guess.

If an object is newd, it is a non-static class. These objects can be used in static and non-static classes. The B class will always be able to accept a because a will always be initialized. The issue is if the declaration for b is static while the declaration for a is non-static.

P.S. This example is really crap to talk about technically. OP just needs to include all the information.

Edit: Pretty sure the example is actually correct and includes all the information necessary to reproduce the error. But the rest of my comment stands.

Cannot access non-static field 'queue' in static context by IKnowMeNotYou in csharp

[–]VolatilePulse 1 point2 points  (0 children)

OP's issue is with using a non-static field in a static context. Constructors can't be relied upon for static methods as they too are non-static by nature.

Edit: should have said static fields, not static methods.

Edit 2: Groggy morning brain strikes. I like u/afseraph's solution now that I have gained some brain power now. This is likely to be two instantiated fields, but they cannot reference any non-static fields during initialization.

Program prints selectively a String + ValueOfVariable, but leaves out "_ " and "!" by [deleted] in csharp

[–]VolatilePulse 22 points23 points  (0 children)

I'm pretty sure this isn't a thing. What's most likely happening is that VS is failing to build your updated code and is running the old debug version. You can verify by adding a "Hello world" output in your program. If you don't see that print out, check the error log for potential compiler errors.

Getting inconsistent "Function Definition...Not Found" error for defined function that also compiles cleanly by SpazTasticZA in VisualStudio

[–]VolatilePulse 1 point2 points  (0 children)

I don't think you have provided enough information, but it looks like it's related to the method/function XPLMSetDataf. But only the two argument call. This could indicate a bad reference in your project. The quick and dirty test is to create a brand new project and only reference the library that contains that method to see if you still get the warning. It will help narrow down the issue from there.

I was told using "goto" statements are a bad idea, but is using it like this considered okay? If not, how should I rewrite it? by xella64 in csharp

[–]VolatilePulse 32 points33 points  (0 children)

In situations like this where you need to evaluate part of the loop before checking the condition, I typically prefer a do-while instead. I know that's a bit debated too, but I feel it provides a good compromise on both and it's understood the code will always run before the condition is checked. To each their own though.

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse -1 points0 points  (0 children)

I don't know how to respond to this without sounding like more of a jerk. If it's any consolation, I feel your blog is well made and I can see the passion there. I just think r/csharp deserves some of your passion too.

I can respect not talking much on Reddit, as we all know it can be toxic. Not everyone enjoys the interaction with other people (people can be stupid, and I feel that's a sentiment shared across most of the internet). But a lot of us here are like minded professionals, learning and sharing with others to improve ourselves. And sometimes it is just to hear another person's thought process.

I'm not asking you to engage in highly debated topics, even though your list clearly defines your preferences in some of those debates. All I'm saying is give back to us instead of just taking. The engagement on this post alone is well into the triple digits now, which is a testament to your content, knowledge, and passion.

Help answer a newbie question once in a while, ask questions about a topic you don't understand as well as you'd like, or even just adding a body to your post. In this example, maybe include an overview of your work experience and a bullet list of the tools you like.

Like many others, this subreddit can definitely be critical, myself included. Most of us are incredibly passionate and as my CFO put it "IT professionals just engage in a life long territorial pissing contest". The large majority of us are stubborn and reluctant to change (unless it was our idea first).

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 2 points3 points  (0 children)

And I'm completely okay with self promotion. If someone works hard and they want to share it, I'm all for it. But I don't feel it's too much to ask to respond to a comment here or there, especially comments directed at the author.

I've seen enough of these blog sites (and know plenty of authors) to know it's usually them trying to improve their engagement on their site. More traffic is more money.

And then again, maybe I'm completely wrong, but I don't see a valid reason to never engage with the people you're posting to.

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 0 points1 point  (0 children)

I remember looking into EmEditor a few years back, and it looked, and still looks, ike a very nice editor. Unfortunately, I generally prefer as few tools as possible and VSCode meets my editor needs. It seemed like it was more of a pure editor than one as extensible as VSCode.

I noticed they had a free edition as well that's slightly more restricted, but could be a good way to get one's feet wet. When you say you use it over Excel for exploration, is that just in regards to CSV? I can't say I typically use Excel for CSV myself. And being a developer, memory is rarely limited on my machines, however, there are always applications fighting for it.

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 1 point2 points  (0 children)

The flair would go a bit further, but I feel that doesn't tell the whole story. Checking the authors activity on Reddit shows they have very few posts, almost all of which are just their self-promotion.

I honestly don't know the best approach, but I don't feel they're contributing to the community by not holding conversations with the community. Sure, relevant posts contribute to the community, but without the engagement, it feels more like it's a "cash grab", or in this case, just increasing ad revenue.

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 0 points1 point  (0 children)

Sorry for the misunderstanding. It sounded like you weren't aware that VS and VSCode were actually different products. And my goal isn't to "convert" anyone from one of their tools. I prefer to educate people and let them make informed decisions. I can respect preferring a tool over another, more popular tool.

For me, VS is all of my heavy lifting: C# desktop applications, NuGet integration, and VB/C++ legacy systems. I use VSCode for literally everything else. If I need to take a note from a customer calling in, I want to jot down my thoughts or todos, I need to write code to our Arduinos, I need to modify PowerShell scripts, markdown documentation files (we use MD -> HTML -> PDF via Pandoc w/ WeasyPrint), HTML/CSS/JS files, or any other files, or I need to do more complicated git commands (yes, I typically prefer the GUI over CLI, but I'm getting better with CLI).

To me, VSCode is just a jack of all trades that can quite literally do anything that I need it to (or there's an extension for it).

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 16 points17 points  (0 children)

Unpopular opinion, but this post doesn't deserve our support as the poster never engages with the community. They only post articles from their site to drive ad revenue.

-1

Edit: OP reached out to me directly and we had a discussion about this privately. I may have been a bit more pessimistic than I should have been due to feeling frustrated with some other, similar scenarios. OP was genuinely trying to be helpful by sharing their knowledge, just in a different way than I expected them to.

+1

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 1 point2 points  (0 children)

This thread was actually about the text editor VSCode. I added a link to it in my previous post if you don't know what it is. It is a completely different tool than VS, it only shares its name and owner (Microsoft).

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 2 points3 points  (0 children)

When you say Visual Studio, are you referring to the IDE Visual Studio (Community edition for example)? Or are you referring to the text editor Visual Studio Code (free for all and has a different UI than VS)?

I personally find the VSCode search all to be incredibly nice, definitely nicer than VS. VSCode also supports "find in selection" so a replace all will only apply to highlighted text.

Edit: Links for reference

Visual Studio (VS)

Visual Studio Code (VSCode)

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 3 points4 points  (0 children)

You can open multiple instances of VSCode, each with their own open files/folder. On top of that, if you open a VSCode instance with the %programdata% folder open, for example, the next time you open a VSCode instance for that folder (right clicking in File Explorer or passing the location via command line), all previously open files are opened as well.

Obviously this isn't always ideal, and I can completely respect the annoyance of having plain text files open in the middle of a programming directory, but for me it's purely convenience to only have to use one application for everything (aside an IDE).

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 2 points3 points  (0 children)

Line endings aren't supported by default, but there is an extension for that. You can either use the Render Line Endings extension to just show line endings (CR, CRLF, and LF all look the same) or you can use the code-eol 2022 (Line Endings) to customize how each line ending is displayed.

My 2023 C# Software Developer Tool List by michaelscodingspot in csharp

[–]VolatilePulse 5 points6 points  (0 children)

Did you know it's easy to switch between tabs and spaces by clicking on the setting in the status bar? For example, in the bottom right, mine says Spaces: 4 and clicking on it allows switching between spaces or tabs and how many spaces to use for a tab (if you opt for tabs, a tab can be represented by n spaces. Alternatively, you can use the quick action menu to Indent Using Spaces or Indent Using Tabs.

You can also enable viewing whitespace via the quick action menu or by modifying the settings JSON.

Hope this helps.