|
I understand, C# is not just a beginners language it’s a language used for serious things.
I’m looking to learn the features with a general purpose scope
|
|
|
|
|
Then you want to learn "patterns"; not languages.
The architect learns about windows and doors before flying butresses.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
A lot of C# features are probably there for dealing with specific tasks ( “link” is for working with databases, etc. ) But I’m sure there are also features useful for any type of project too
>Then you want to learn patterns.
I can’t imagine a learning resource that teaches abstract programming rules.
|
|
|
|
|
You don't need wood and bricks to learn about windows.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Calin Negru wrote: “link” is for working with databases, etc.
linq (spelling) was not added to deal with databases. It was added as a result of a surge of interest, or at least perceived interest, in functional programming.
Then someone decided it would be a 'good' idea to use linq to access databases.
They were wrong.
They were not also the first ones to think that a generic in language source would somehow be better for database access. Long before that C++ (or maybe java) had an alternative in the language (sort of) for SQL. But it never took off. Probably for the similar reasons as it made simple problems simpler (which was never a complaint) but complex problems either difficult or even impossible to deal with.
|
|
|
|
|
LINQ doesn't "do databases"; it does "data models". The "source" of the model varies: database; objects; XML. An architecture that allows for "new" types of sources. Most issues are due to not understanding the client / server relationship and the purpose of stored procedures.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Gerry Schmitz wrote: LINQ doesn't "do databases"; it does "data models". The "source" of the model varies: database; objects; XML
No idea how that changes what I said.
Gerry Schmitz wrote: Most issues are due to not understanding the client / server relationship and the purpose of stored procedures.
I can't speak as to the source of of your "most" comment. But I can speak as to the problems I found of which I do not believe any had to do with stored procedures.
|
|
|
|
|
Gerry, jschell
The problem is I’m not programming a server or a client or anything that has to do with databases. Besides there is nothing in c++ like it AFAICT
I’ve had a brief contact with C# list accessories ( the stuff used to interact with a list in different ways) it seems like that’s what I’m looking for. C++ vector has some of those things too.
|
|
|
|
|
I have an in-memory collection; it contains "blocks"; these blocks represent different types of troops; these troops belong to different "teams". Some blocks (brigades) have other blocks as children. Some blocks don't belong to any team.
If I wanted to retrieve all "blue" infantry that were not currently in action, etc .... that's LINQ "to objects".
LINQ, when used properly, gets rid of a pile of if's and for loops while doing "object oriented programming".
If you're strictly "procedural", then none of this works for you.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
OriginalGriff wrote: easier to learn how to think like a developer in C#
Which is the main issue as I see it. C# is easier than C/C++, which is a major strength. But learning it leaves a developer unprepared for C/C++ being hard. By which I mean that garbage collecting and such -- memory allocation and cleanup , references , etc. -- may be best learned in C/C++ before C#, as we oldsters did.
I don't recommend C/C++ to any new developer unless they really need to learn it for some particular task.
Basically I skipped C++ anyway and went from C to C# with barely a look back.
|
|
|
|
|
I went from Assembler to C to C++ to C# - and haven't looked back! The productivity improvement is absolutely priceless.
Now, if I was still doing embedded work it would be different, but ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yeah, barely had an introduction to Assembly (VAX Macro 11), quite a bit of C, just a dabbling of C++, and now C# for the past twenty years.
|
|
|
|
|
I can strongly recommend C# in Depth[^]. You can buy copies from Amazon.
|
|
|
|
|
Thanks for the suggestion
|
|
|
|
|
Calin Negru wrote: to get better at c++ I need to improve my c# skills Why do you think this ?blockquote class="quote">Calin Negru wrote: I remember seeing helper constructs that make certain operations when dealing with lists easier but at that time I could not understand themCan you understand them now ? Study LINQ !
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Bill your post seems to have some formatting problems
|
|
|
|
|
I need to call Google's People API from a WPF app. Google has mandated that you cannot use embedded browsers any more[^].
Therefore, my app need to open the browser, presumably with Process.Start() to Google's Authentication page, and then somehow detect if/when the user has been authenticated.
How would you go about that?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Microsoft provides a group of thread-safe collections, but conspicuously does not provide a thread-safe List<T>. What is the reason? Is it not feasible to make a thread-safe version of a List<T>?
I need an ordered, sortable collection that is thread-safe.
I might get flamed, but I'm about to copy and paste some code I found on the internet. On stack exchange, I found the following post:
https://codereview.stackexchange.com/questions/62033/creating-a-thread-safe-list-using-a-lock-object[^]
To me, it looks like it would work and be thread-safe.
I'm wondering if some more experienced and respected members can tell me if this code looks like it might indeed be thread safe. The key bit about this code is that it uses callbacks to be able to keep the collection locked even while enumerating it or performing some other types of access.
I have reproduced the code below for convenience:
(If you consider this post inappropriate due to its length, please let me know, and I won't do it again.)
public class ConcurrentList<T> : IList<T>
{
#region Fields
private IList<T> _internalList;
private readonly object lockObject = new object();
#endregion
#region ctor
public ConcurrentList()
{
_internalList = new List<T>();
}
public ConcurrentList(int capacity)
{
_internalList = new List<T>(capacity);
}
public ConcurrentList(IEnumerable<T> list)
{
_internalList = list.ToList();
}
#endregion
public T this[int index]
{
get
{
return LockInternalListAndGet(l => l[index]);
}
set
{
LockInternalListAndCommand(l => l[index] = value);
}
}
public int Count
{
get
{
return LockInternalListAndQuery(l => l.Count());
}
}
public bool IsReadOnly => false;
public void Add(T item)
{
LockInternalListAndCommand(l => l.Add(item));
}
public void Clear()
{
LockInternalListAndCommand(l => l.Clear());
}
public bool Contains(T item)
{
return LockInternalListAndQuery(l => l.Contains(item));
}
public void CopyTo(T[] array, int arrayIndex)
{
LockInternalListAndCommand(l => l.CopyTo(array, arrayIndex));
}
public IEnumerator<T> GetEnumerator()
{
return LockInternalListAndQuery(l => l.GetEnumerator());
}
public int IndexOf(T item)
{
return LockInternalListAndQuery(l => l.IndexOf(item));
}
public void Insert(int index, T item)
{
LockInternalListAndCommand(l => l.Insert(index, item));
}
public bool Remove(T item)
{
return LockInternalListAndQuery(l => l.Remove(item));
}
public void RemoveAt(int index)
{
LockInternalListAndCommand(l => l.RemoveAt(index));
}
IEnumerator IEnumerable.GetEnumerator()
{
return LockInternalListAndQuery(l => l.GetEnumerator());
}
#region Utilities
protected virtual void LockInternalListAndCommand(Action<IList<T>> action)
{
lock (lockObject)
{
action(_internalList);
}
}
protected virtual T LockInternalListAndGet(Func<IList<T>, T> func)
{
lock (lockObject)
{
return func(_internalList);
}
}
protected virtual TObject LockInternalListAndQuery<TObject>(Func<IList<T>, TObject> query)
{
lock (lockObject)
{
return query(_internalList);
}
}
#endregion
}
The difficult we do right away...
...the impossible takes slightly longer.
modified 21-May-23 16:33pm.
|
|
|
|
|
Deja vu.
.Values collection of a concurrent dictionary.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Gerry, thank you for your post. I didn't mention in the original post that I need an ordered collection that is sortable.
I don't see that the .Values collection supports sorting.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
"Sortable". Before, during, or after? One time or repeatedly? You can built multiple dictionaries over the same set all having a different order ... the "keys collection" is then in order (with which to retrieve the "values"). Or, sort the values before loading them with an "entity id.".
All the concurrent collections require some sort of "destaging" if you want a "list"
I didn't think you actually meant you wanted to be able to (live) sort a "concurrent" (list) file.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
modified 22-May-23 18:07pm.
|
|
|
|
|
? [^] ... a Collection with unspecified order.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
You woke up just for that?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|