Search results for query: *

  1. kareninstructor

    I have a question about Re-Entering Try Catch

    Check out Spectre..Console. In the code below the generic method Get only accepts int, not decimal or double. If they press ENTER the default value of 0 is set to the variable. using System; using Spectre.Console; namespace ConsoleApp1 { internal partial class Program { static...
  2. kareninstructor

    How to keep a log file from growing too big

    With SeriLog, write to a new file each day and if desire remove old folders after a period of time. Also, SeriLog supports writing to a database so as with writing to a file you can write a job to remove old records. See the following GitHub repository for various samples and best practices.
  3. kareninstructor

    Why do some C# applications have an app.config file and others do not?

    Seems like one option for sticking with app.config is to create a custom template with an app.config in the project and manually add in code to get settings. public class PositionOptions { public const string Position = "Position"; public string Title { get; set; } = String.Empty...
  4. kareninstructor

    Question Run-time implementation of Enum

    If considering using T4 templates see one of mine here. Note in the link I've provided guidance on ways to colorize templates as Visual Studio does not natively support T4 template syntax coloring. There is a script included to create the database. Also, although the code uses NET8 the template...
  5. kareninstructor

    Question Why do I keep reading that learning/understanding C language first will make you a better programmer?

    Coming from an Assembler to C as first languages all I can say is happy to leave them behind. Perhaps there might be a small edge on knowing C but not anymore with the Visual Studio ecosystem.
  6. kareninstructor

    Resolved Login form with Access db help

    Try FormMain().ShowDialog();
  7. kareninstructor

    Question Where to start learning to use the Visual Studio IDE

    For learning C#, check out the following book C# 12 and .NET 8 – Modern Cross-Platform which I have no read but was highly recommended by a Milan Jovanovic who I know from Twitter. Another resource is Foundational C# with Microsoft. There are really no books on learning Visual Studio but check...
  8. kareninstructor

    Question which better using entity framework core or ado.net data reader ?

    True that there is a erasure issue yet some of this can be handled with partial classes for EF Core or if the changes are small enough and working with dependency injection the changes in a DbContext should not matter as the connection aspect would be (for ASP.NET Core for instance) in...
  9. kareninstructor

    Question which better using entity framework core or ado.net data reader ?

    Considerations, with ADO, in your current code, if column names change in the database table(s) you need to manually update your code while with EF Core using EF Power tools simply run the reverse engineer process again and all code is updated. Also, everything is strongly typed. As indicated by...
  10. kareninstructor

    Question getting data from db and put into list

    A good places to start, learn C# Microsoft C# W3 schools SQL W3 schools Tips Take your time learning C# and SQL basics Start with the basics for C#, do not be jumping into the deep end (deep end means you are not familiar with a specific method of coding). Work with console projects to...
  11. kareninstructor

    Hi guys been trying to learn C# on my own.

    Free is not allows the best way to go if committed to learning and to get a job, expect to spend at least two years of learning how to programming. Get started with learning how to work with databases with a recommendation with SQL-Server without C# as any job that uses C# will need database...
  12. kareninstructor

    Free C# library to save as Excel file

    I wonder about this and what stopping them from downloading but alas even know that I still find value in posting it. Perhaps if this is because of a company policy they might ask for an exception to the rule.
  13. kareninstructor

    Free C# library to save as Excel file

    Look at SpreadSheetLight which is a free to use library for .xlsx Excel public static void ExportToExcel(DataTable table, string fileName, bool includeHeader, string sheetName) { using var document = new SLDocument(); // import to first row, first column document.ImportDataTable(1...
  14. kareninstructor

    Question How to get list of checkboxes not checked on page model razor page?

    See my article ASP.NET Core/Razor pages working with Checkboxes which takes a different approach than what you are doing. OnPost Logging in this case is SeriLog public Task<IActionResult> OnPostResendAsync() { // get checked var checkedItems = CheckModels.Where(x =>...
  15. kareninstructor

    Question error object reference null after click submit button ?

    Here is an example that has two submit buttons, first redirects back to the same page passing a string then in the Get sets a property which in turn on page load presents a popup while the second submit does nothing other than write to the console. Full source using Microsoft.AspNetCore.Mvc...
  16. kareninstructor

    I made a password generator and I think my code isn´t the best readable. Are there any better ways to do it?

    Realizing this is a month old question thought it is still worth posting the following example which is done with .NET Core, C#9 which will need modifications if using .NET Framework. To keep code clean and concise, consider using NuGet package SnippetSpectre.Console. Collecting user input...
  17. kareninstructor

    Is there any free library to automatically generate test cases for .net?

    Have you looked at SpecFlow where you first write out scenarios using TDD style of coding e.g. Given...And...When...Then. SpecFlow is free now.
  18. kareninstructor

    Is there any free library to automatically generate test cases for .net?

    In Visual Studio you can create stub unit test.
Back
Top Bottom