If you know OOP stuff then read Clean Code by Robert C. Martin for good coding style.
Learn WPF and MVVM pattern and... well.. code stuff! You can't learn with just reading about stuff. Even trivial things can help you to become better programmer.
Maybe a TV series database client?
Do you know a program called "Total Commander"? Make a copy of it. Just without freaking clicking 1, 2 or 3 every time it starts running.
You do not have to invent a wheel in your project. Pick an application and copy it. Yes, there might be topics which you are not familiar with, but hey, using google is also a sign of being a good programmer.
If you are bored you can solve coding challenges on sites like https://edabit.com/.
Interfaces create a shared contract between classes. Basically... "everything has to have these methods and return types". The compiler now has a guarantee that every class with that Interface will have these methods and can run code between any Classes that use it interchangeably. Which allows for much more flexible code, because we can pass the Interface structure around, which allows all the classes using that Interface to be treated the same way, regardless of implementation details.
Some links that might help:
You haven't really explained your question very clearly. Let's see if I understand it...
You have TextBox1, where the user can type something.
You have TextBox2, which contains a string to match.
As the user types into TextBox1, you want the text in TextBox2 to change colour; green if the user's input matches it. (Some other colour if there's no match?)
Is that right? If not, please try to explain again.
Because you want TextBox2 to be only green where it matches the user's input (i.e. you need more than 1 colour displayed) you can't use a TextBox control, since that only allows 1 foreground colour and 1 background colour. You'd have to use a RichTextBox instead. Perhaps this StackOverflow question & answer might point you in the right direction for the colouring.
> if(textbox1 == textbox2) {do stuff}
That will only work for a full match (if the 2 textboxes contain exactly the same), not a partial match.
> Would regex be the best solution
Possibly, but probably not. It depends on exactly how you want it to work.
If you want to see if TextBox1's value is an exact match for the start of TextBox2's value, then you'd want something like:
if ( TextBox1.Text == TextBox2.Text.Substring( 0, TextBox1.Text.Length ) ) { ... }
If, instead, you want your colouring done on a character-by-character basis (e.g. the user types "Hallo" and you want the Hllo
in green but the a
in red) you might just want to check a character at a time;
for ( int i = 0; i < TextBox1.Text.Length && i < TextBox2.Text.Length; ++i ) { if ( TextBox1.Text[ i ] == TextBox2.Text[ i ] ) { // This character can be shown in green } else { // This character can be shown in some other colour. } }
I did what you said and moved the initialization of random outside of the loop and worked.. but I am not sure why...
int[] rolls = new int[timesToRoll]; Random ranSeed = new Random(); for (int i=0;i<timesToRoll;i++) { rolls[i] = DieD6(ranSeed); }
static int DieD6(Random ranSeed) { int n = 0; n = ranSeed.Next(1, 7); return n; }
FULL FINAL CODE : https://hastebin.com/xoqomibuyu.cs
I use EPPlus (v4.5.3.3 and earlier are open source) for reading/writing Excel files. There are other libraries like ClosedXML that provide similar functionality.
As for you specific scenario, either read a set number of rows for the value pairs or read each row until you get to an end point, such as an empty row, then you can read the tabular values.
The ecosystem (package manager) is called NuGet and is now baked into Visual Studio. According to their stats page, there were 230M packages downloaded last week.
For fast track, consider porting some of your smaller projects from other languages to C#.
Off the top of my head I don't know the solution to that but, as an alternative approach, have you considered using something like AutoIt or AutoHotKey to do the click automation? Depending on what else your WinForms program is doing one of those might be a more suitable tool for the job.
It depends on how the whole thing is structured, but if you want to add the functionality to the same program you'll want to make a new class.
Classes are a way to keep your code organized so the name should make sense based on what the class needs to do.
If the new class you create is in the same namespace as your Program class (which it will be if you use Visual Studio, I'm not sure about VS Code) then you can use the newly created class without doing any additional work.
If they're in different namespaces, you'll have to add the correct "using" statement to the top of the new class.
If the tutorial you're following is online, it might help to link it.
EDIT: If you can spend a little money, The C# Player's Guide (3rd Edition) is really good for learning C# and some CS basics (like data types and classes).
Refactor your code, it's way too busy. When you are doing too much all in one class or method. It gets much harder to really know for sure what is blowing up, or causing the real issues. Sometimes it's a chain of events or a compound issue. Limiting the scope of everything can be very useful. You can easily see exactly what inputs it wants, what process/variables are involved, and what the output should be. Look into some Clean Code examples for more tips.
Some random examples of simplifying your method calls, so if a method doesn't work, but everything else did before that. It's easier to know exactly what to fix inside the method that blows up.
private static void findTitles(){ // Display List of Titles that user has posted // Output Titles }
private static void editListCategory(string Title){ // Given the Title, update it's Category, Title, Price, Description string case = Console.ReadLine(); switch(case.ToUpper()){ case C: editCategory(); break; default: Output - "Try using C, D, P, T or use Q for quit" } }
editCategory(){ // output options - "Free, Sell, Rent", prompt and assign }
It's usually easiest to create a method that handles prompts, instead of writing a new one everywhere. Depending on needs.
private static string prompt(){ return Console.ReadLine(); }
Example of a more complicated prompt with more flexibility
private static string prompt(string Title, string Description, string[] validAnswers){ do { Console.WriteLine(Title); // Pick a Title to Edit Console.WriteLine(Description); // User prompt with expected answers string answer = Console.ReadLine(); } while ( !validAnswers.Contains(answer) ); return answer; }
https://stackoverflow.com/q/30285135/8093553
I guess I was wrong, you just cant use it with a big company and stuff. I think i was confused with a product that only lets you publish applications if you have a paid license. Sorry :)
Learning on a mobile phone? Ouch. For offline compilation, only C# Shell is regularly updated. For your sanity though, just get a PC.
Look on youtube for Nick Chapsas and if you like his style you can buy his course on unit and/or integration testing here: https://nickchapsas.com/p/from-zero-to-hero-testing-essential .
I can not say if the courses are worth it or not because I dont have them yet, but I am going to buy them soon.
And for a quick start in csharp i found this book really interesting https://www.amazon.com/10-NET-Cross-Platform-Development-websites/dp/1801077363/ref=mp_s_a_1_1?qid=1654734930&refinements=p_lbr_one_browse-bin%3AMark+J.+Price&s=books&sr=1-1
Honestly, buy this book: The C# Player's Guide (5th Edition) https://www.amazon.ca/dp/0985580151/ref=cm_sw_r_cp_api_i_CM9G9DQPPYH3QJ9SSP4T?_encoding=UTF8&psc=1
It is by far the best programming book I’ve ever purchased.
Casual language with a light style that is easy to read combined with an RPG theme to “level up” from doing challenges as you read material and learn concepts.
Sounds like a gimmick, but it is extremely thorough and the examples are much better than the foo = bar crap that doesn’t give any real world context.
Have fun learning!
I have all of my devs read Domain Driven Design: Tackling Complexity in the Heart of Software by Eric Evans for a good understanding of how we build enterprise software. I also have them read Clean Code: A Handbook of Agile Software Craftsmanship.
Both of these, for different reasons, can help a lot with building out good, sustainable architectures.
I would read it from the source since they explain it best: Gang of Four Design Patterns Book
I also find this to be a great source of examples in C#: Refactoring Guru: C#
That being said, the observable and state design patterns are not mutually exclusive (or any of them for that matter). You can use both in your solution. For example: you can use the observer design pattern to set the state of your subscribers.
Your solution could range from any of those design patterns, just make sure you understand how they work.
Best of luck in your endeavors!
With SSRS, you do not need a full blown server to generate reports. You can make use of the "LocalReport" class within the library.
Resharper likes to make all private member variables start with " _ " (underscore) and since that was what work uses for projects I have been involved with I just go with flow (though that may been different in other teams) though it should be noted - Googling for C# style guides came up with one on dotnetspider that also uses " _ " (underscore) for same purpose, other guides linked from here wanted an email address to download so not bothering with to check.
Individuals can use it commercially. Restrictions don't kick in unless you fall under organization/enterprise, and even then they vary depending on project type, amount of users, and yearly revenue.
https://visualstudio.microsoft.com/license-terms/vs2022-ga-community/
> All right. Sorry about the delay. I was away from my keyboard for the last two weeks, and I wanted to be able to type this out on a PC instead of using my thumbs on a phone.
No problem at all! Thank you for the detailed response, that's way more I expect from a random dude on the internet to help another random dude.
> That last point is the reason why we stay away from NuGet packages at our company. We only use NuGet for a few select things, like library functions that contain no business logic and change very infrequently [...].
I can agree and understand your points and distributing business logic through different services via nuget will lead to a distributed monolith. But that's not what I was meaning with my point #3 (*).
For example we do have a important service that has an API built around ZMQ and many clients that need to interface that service. We have a central library implementing that interface, but no business logic. So it's more like Azure.Storage.Common [1]. I am looking for a solution for these kind of libraries.
What I and my senior C# developers mean with co-evolution of different projects is that right now, if there is a problem with a library, I can just step into it with my debugger, find the bug, fix it in-situ and verify that it works now and later publish the fix to the libraries repository. With nuget's I suppose I'd have to fix the bug first, publish a new package and only than can I verify that it works for my use case.
[1] https://www.nuget.org/packages/Azure.Storage.Common/
(*) If we were doing this, we would be distributing that business logic by copy pasting right now. I guess at that point, I'd just quit.
This probably isn't the answer you want, but it sounds like you might be able to do what you want easier with something like AutoIt or AutoHotKey, rather than writing your own C# program, since they make interacting with other programs comparatively simple.
For an mqtt client library, I'd have look at paho eclipse. I've used their python library, which is great.
https://www.eclipse.org/paho/clients/dotnet/
So, if each location will be storing to a database, it sounds to me like you would want access to the Watchdog code or direct access to the sensors providing the data so that you can publish it over mqtt as it becomes available. Then, your dashboard app is going to be subscribed to all the topics from the various locations and display some sort of real time visualization, like some graphs or whatever.
Figure out what code you can run at the different locations to publish the data. Figure out how to present the collected information in a way that is useful. See here for example implementations: https://thingspeak.com/
i started learning C# this year as well and started off with https://codeasy.net/ first part is free second and third are not. after that i did Solo Learn just to see if i missed anything. now i am doing Code Wars and gonna start creating my own program from scratch. i hope it helps.
Depending on exactly what you want to do, you could give the Open XML SDK a try. It's developed by Microsoft to manipulate Office files (Word, Excel, PowerPoint) and requires no interop. This means you don't even need Excel installed to work with Excel files.
There's also a 3rd party library called ClosedXML, which is a wrapper around Open XML. ClosedXML aims to make it easier to work with Excel files specifically.
Console.WriteLine(res.Substring(17,168)); //grabs just the token itself
No no no, use a JSON parser like JSON.net (https://www.nuget.org/packages/Newtonsoft.Json/) to get the value!
Also, can I recommend using something like https://flurl.io/ to send rest request rather than writing it from scratch each time? There are too many gotchas with HttpClient to justify using it on its own.
Wow. OK, I am going to mostly spare you the lecture on how this should really be working with an actual database system over an excel spreadsheet (There's lots of free ones out there), but seriously... Look into it.
​
Anyway, in the application you are writing that is responsible for talking to the Excel Spreadsheet you are going to want to add a reference to DocumentFormat.OpenXML via the NuGet Manager. This allows you to read/write to various MS Office file types including MS Excel. From there it is on you to sort out reading and parsing the information to be brought into your app. If you're lucky the Flanges and Welds are on a distinct sheet on their own and it is just a matter of going to that sheet in the work book and reading all the values for one or the other. if you're unlucky, all of these are in one big lump on a sheet named "parts" or something and you have to read them all in and figure out which ones are welds and which ones are flanges. Without an example of what the spreadsheet looks like I can't really get more specific, but hopefully this starts you down a good path towards figuring it out.
I'm also using solo learn - it's okay for the topics/overview, but I don't like that it's mainly hands off as I prefer something more interactive. I was surfing around a few weeks ago and someone had mentioned Edabit (https://edabit.com/) - This place has actual coding challenges/exercises that you can use to test your skills. I'm still extremely new to this, but this site has helped me reinforce the extreme basics so far.
If you're willing to spend a few bucks, I'd recommend going to Pluralsight.com. It'll cost you $30 per month. Among the garbage on Youtube, there is actually some decent content for it. Go there and search for Kudvenkat to start. There is a whole series there on ASP.NET Core.
If you don’t want to buy a computer you can always have one in the cloud, I use Shadow for personal dev stuff, I connect to it on iOS or Android and a Samsung Dex
You have to wait for activation which can’t are some time depending where you are but it’s decent spec, decent price and means you can do what you can do on a “proper” pc without having to buy a pc from anywhere.
on further inspection of the question (and my not that amazing answer):
Try ArrayList:
Actually storing it in the localstorage is more vulnerable than the httponly cookie, this is because the localstorage is accessible through Javascript running on the same domain, therefore vulnerable to XSS attacks, read here for more info. If you store the refresh token in the localstorage, the data stored will persist until explicitly deleted. Changes made are saved and available for all current and future visits to the site so you'll need to remember to clear it out when you're done with it.
Its true that cookies can also be vulnerable, however httponly and secure cookies will mitigate that to some extent. The link you've provided mentions that httponly cookies can be set to prevent XSS attacks as it can only be accessed server-side.
Its worth noting that storing the access token in the session storage might cause problems because it will be deleted as soon as the tab/window is closed. Therefore, your users are only authenticated via one tab, opening a new tab or window on the same domain will not be authenticated I believe and so will require your users to login again (though I'm not 100% sure).
I wonder if your current implementation is the correct way. Shouldn't the access token be sent on loading the login page to see if the user is authenticated or not? If so, then redirect to the default webpage. The refresh token is designed to 'refresh' the access token only once it has expired, invalid or doesn't exist.
In any case, I would still recommend you store your refresh token in a httponly and secure cookie instead of the localStorage to at least prevent hackers from accessing it via Javascript.
Well, I just learnt by doing so I can't recommend any resources. To get started though, just head over to this page:
https://www.microsoft.com/en-us/sql-server/sql-server-downloads
then download the developer version (it's free) and install it. Once that's done you can either let me know and I'll help you get connected or you can find resources elsewhere.
You'll probably want this too:
It's a software that connects to databases and you can run queries and see outputs easily. It looks crazy confusing but 99% of it can be ignored.
It starts really simple.
Like I just launched C# task, and it showed me this:
https://www.codewars.com/kata/5265326f5fda8eb1160004c8/train/csharp
This is like a single method call. Or a single loop if you want to do it manually.
I also just read your post again: your approach is not threadsafe. If two users are making items at the same time, user A's order might get linked to user B's items!
The right way to do this is to hold the returned result of the first INSERT statement, and use it to populate the FK of the second statement. See the RETURNING clause (although if this is omitted then the primary key is returned anyway) - again, how you get this is dependent on how you connect to your database.
I believe dotnet
is for more modern projects written in 4.6 something and above or in .NET Standard or .NET Core.
You might want to try building it using msbuild.exe from here:
https://visualstudio.microsoft.com/downloads/?q=build+tools
> Build Tools for Visual Studio 2019
> These Build Tools allow you to build Visual Studio projects from a command-line interface. Supported projects include: ASP.NET, Azure, C++ desktop, ClickOnce, containers, .NET Core, .NET Desktop, Node.js, Office and SharePoint, Python, TypeScript, Unit Tests, UWP, WCF, and Xamarin.
Once you have those you can run the exe and point it to your project.
Beep. Boop. I’m a human. Here’s a copy of
I read this book Pro ASP.NET MVC Core 3 cover-to-cover when it first came out. (Well, it was call Pro ASP.NET MVC 1.0 back in 2009). It taught me how to built ASP.NET MVC websites with C#.
Although, unlike you, I already had many years of C# under my belt.
I'm afraid you might be biting off more than you can chew. If you're only just getting C# and the basic fundamentals down, this may still be out of your reach. You'll definitely want a mentor to help you along.
Design patterns are pretty abstract--you can probably get a lot out of Head-First Design Patterns, even though it uses Java for its example code.
You may find Code Complete or The Pragmatic Programmer useful or educational, too, though neither is particularly focused on the ins and outs of C# or .NET.
I really have enjoyed "C# 6.0 In A Nutshell...": https://www.amazon.com/C-6-0-Nutshell-Definitive-Reference/dp/1491927062 I actually know someone that's pretty proficient in C# and he has been making a youtube series on it right now: https://m.youtube.com/watch?v=sK5K2n3GeVc I think it is a great resource for beginners/intermediates.
I can suggest you C# 6.0 and the .NET 4.6 Framework. Also CLR via C# nice one, but not for beginners
The C# Programming Yellow Book, only $0.99 -- and it isn't a gimmicky half-book you tend to find for that price on Amazon; it's a full-length instructional text that takes you from beginner to intermediate.
For late-intermediate to advanced, I've heard a lot of good things about C# In Depth, but I haven't tried it myself.