C Sharp

1754 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 2 years ago
MODERATORS
151
152
153
1
.NET Digest #3 (pvs-studio.com)
submitted 1 year ago* (last edited 1 year ago) by AlexKochetkova@programming.dev to c/csharp@programming.dev
154
155
156
1
submitted 1 year ago* (last edited 1 year ago) by DrDeadCrash@programming.dev to c/csharp@programming.dev
 
 

A collection of tools for dealing with nulls, failures and the generic type issues that arise in this domain.

https://github.com/Andy3432344/SafeResults

I'm the author, let me know what you think!

*Edit: updated to show GitHub link, sorry!

157
 
 
158
 
 

From the meeting minutes:

First up today, the discriminated unions working group presented the proposal they've been working on for a while to the broader LDM. This was a broad overview session, rather than a deep dive into nitty-gritty questions; there are still plenty of little details that will need to be filled in, but we're cautiously optimistic about this proposal and moving forward with it. There was some concern about some of the ternary behavior, but we can dig more into that as we bring this proposal back for detailed follow ups in the future.

159
 
 

Let's say I have a method that I want to make generic, and so far it had a big switch case of types.

For an simplified example,

switch (field.GetType()) {
case Type.Int: Method((int)x)...
case Type.NullInt: Method((int?)x)...
case Type.Long: Method((long)x)...

I'd like to be able to just call my GenericMethod(field) instead and I'm wondering if this is possible and how would I go around doing it.

GenericMethod(field)

public void GenericMethod<T>(T field)

Can I use reflection to get a type and the pass it into the generic method somehow, is it possible to transform Type into ?

Can I have a method on the field object that will somehow give me a type for use in my generic method?

Sorry for a confusing question, I'm not really sure how to phrase it correctly, but basically I want to get rid of switch cases and lots of manual coding when all I need is just the type (but that type can't be passed as generic from parent class)

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
 
 

Hi all. I've been wanting to get into programming for a while now, specifically C#. However, I am not good at self-study or self-guided learning. Are there any good textbooks/workbooks that you'd recommend to learners of C# as a first programming language? I have some experience with coding, but not much more than simple command-line calculators (due to aforementioned lack of self-teaching skills).

To clarify, I'm looking for a straightforward textbook where I could read a chapter and do the associated "exercises" (for lack of a better word)

view more: ‹ prev next ›