C
C#โ€ข2y ago
oldcoder

โ” About learning C# and Asp.net core

Hello guys, i wanna ask something about learning path to web development with c#. I am learning C# for a while and haven't make any project yet i only followed courses and had theoretical knowledge. So, when I can jump to asp.net, should I make projects with C# before, or can I learn C# better in Asp.net. I will learn C# for web development and as i see, there is no "plain C# backend" thing.
201 Replies
JakenVeina
JakenVeinaโ€ข2y ago
there is no "plain C# backend" thing
what do you mean by this?
oldcoder
oldcoderOPโ€ข2y ago
well, for example at frontend you can make a lot things with plain js without libraries or frameworks
Pobiega
Pobiegaโ€ข2y ago
you certainly can make a web backend without ASP.NET, but it will be extremely painful . I highly recommend not even trying, as its not realistic. Unlike JS frontends where you have 10+ framework options, in .NET we have one serious option for backend development, and thats ASP.NET
oldcoder
oldcoderOPโ€ข2y ago
yea my point is definitely that. I dont know should i start making projects with ASP.NET, or making projects with C#, maybe not related with web or yes. I dont wanna use Forms or console apps, and my knowledge is so shallow at C#
Pobiega
Pobiegaโ€ข2y ago
I'd suggest learning the basics with console apps first since it has a lower barrier of entry but once you know classes, methods, variables etc, you can start with some simple stuff in ASP.NET
oldcoder
oldcoderOPโ€ข2y ago
hmm so you are saying jumping into asp.net and learning c# with it is better i mean learning that "diving deeper and being advanced", not basics
Pobiega
Pobiegaโ€ข2y ago
kinda. I'd say it works, and if thats what you wanna do, do it.
oldcoder
oldcoderOPโ€ข2y ago
But my concern is different
Pobiega
Pobiegaโ€ข2y ago
I often have 2 solutions open at a time: the (usually web) project im working on, and a console app "playground" for testing small concepts
oldcoder
oldcoderOPโ€ข2y ago
I tried to work with asp.net core mvc razor project, (via copy-paste) it
Mayor McCheese
Mayor McCheeseโ€ข2y ago
Like a scratch pad?
oldcoder
oldcoderOPโ€ข2y ago
and i saw different things which dont exists at tutorials and "basics courses" like [] top of functions
Pobiega
Pobiegaโ€ข2y ago
Kinda.
oldcoder
oldcoderOPโ€ข2y ago
and i saw different things at language docs which dont exists at tutorials like delegates, structs, records, etc
Pobiega
Pobiegaโ€ข2y ago
... you mean attributes? That's definitely in most asp tutorials
oldcoder
oldcoderOPโ€ข2y ago
@pobiega yea, and other features like above. There is a thing like "some things not in tutorials" and like "some things only appear at asp.net"
Pobiega
Pobiegaโ€ข2y ago
You won't find every single language feature documented heavily in a random tutorial
oldcoder
oldcoderOPโ€ข2y ago
i finished tutorials but i didnt see anything like delegate or records (C# language tutorials not asp.net) and as i see, that things not used in asp.net
Pobiega
Pobiegaโ€ข2y ago
Records are extremely common in asp.net Both records and delegates are just core language features they're not specific to asp.net but they're also not specific to win forms or console
oldcoder
oldcoderOPโ€ข2y ago
for example if i give examples from javascript there is nothing special to frameworks everything is JS, and you can learn them when you finish a course or tutorial
Pobiega
Pobiegaโ€ข2y ago
That's not true either look at jsx and hooks from react for example
oldcoder
oldcoderOPโ€ข2y ago
@pobiega yea but i mean you are still using js knowledge hooks are functions for ex
Pobiega
Pobiegaโ€ข2y ago
How is that different in c sharp
oldcoder
oldcoderOPโ€ข2y ago
i am trying to say "i finished C# tutorials and didnt see that things used at asp.net"
Pobiega
Pobiegaโ€ข2y ago
Just like I'm sure finishing a single reactorial won't teach you all the Advanced Concept there
oldcoder
oldcoderOPโ€ข2y ago
is C# knowledge not enough to use ASP.NET we can say
Pobiega
Pobiegaโ€ข2y ago
Not sure what you are on about
oldcoder
oldcoderOPโ€ข2y ago
people say "when you know javascript you can use any frameworks you want"
Pobiega
Pobiegaโ€ข2y ago
Basic http understanding and basic C# is all you need Yeah but you'll still need to learn the frameworl That's true for asp too
oldcoder
oldcoderOPโ€ข2y ago
but for me its not true, i cant use any framework which i dk hmm, so can we say "this is special for asp.net" like react hooks
Pobiega
Pobiegaโ€ข2y ago
In a way? Hooks are just functions, and asp actions are also just functions But they behave a bit special
oldcoder
oldcoderOPโ€ข2y ago
hmm when i should jump to asp.net from c#
Pobiega
Pobiegaโ€ข2y ago
You can start once you know classes and methods So quite early But you will need to learn a lot of stuff in one way or another
oldcoder
oldcoderOPโ€ข2y ago
actually there is C# 101 and 201, i finished C# 101 but it says advanced for 201 so i didnt look at that. should i make projects with c# before jumping to asp.net, if so how those will be related with web without using asp.net or maybe dont care asp.net and make things with c# to understand it better, then jump to asp.net idk
Pobiega
Pobiegaโ€ข2y ago
Either is fine. If you are exclusively interested in doing web stuff with C#; go directly to asp.net imo but learning the fundamentals can be easier in a console app, until you are more familiar
cap5lut
cap5lutโ€ข2y ago
i agree with Pobiega, i think u can jump to asp.net as u have most of the fundamental stuff learned now. these [Blah] things are called attributes, there is not really a generic way to teach them as most libraries provide their own to give special meaning to what ever it attributes (methods, fields, properties, types, etc) and any not too shabby asp.net tutorial would explain them. the only thing that didnt come up yet is async/await, but thats not really a requirement to get started either and tutorials will cover that along the road as well
oldcoder
oldcoderOPโ€ข2y ago
actually i made an app with c# (asp.net core mvc), but its frontend was c# not javascript. and i dont know "how can i make a backend for a ready-made frontend with c# "
Pobiega
Pobiegaโ€ข2y ago
just make a web api no frontend attached. dotnet new webapi
cap5lut
cap5lutโ€ข2y ago
records is more or less just fancy syntax stuff to avoid boilerplate.
public sealed class MyDTO
{
public int Id { get; set; }
public string Name { get; set; }
// implementation for Equals and alike
}
public sealed class MyDTO
{
public int Id { get; set; }
public string Name { get; set; }
// implementation for Equals and alike
}
and public record MyDTO(int Id, string Name); would be the same to give an example structs u dont really have to care about they arent that common in web, as this is more for value types/optimizations
Mayor McCheese
Mayor McCheeseโ€ข2y ago
Plus it gives a lot of ruminations about how to handle records and file names ๐Ÿ˜‰
cap5lut
cap5lutโ€ข2y ago
and delegates are more or less just "method types", u will rarely write them urself, but mostly use some methods, eg. if u ever used linq, u most likely have passed lambdas as parameters, these will be converted to delegates:
var oddNumbers = someNumberList
.Where(n => n % 2 == 1)
.ToList();
var oddNumbers = someNumberList
.Where(n => n % 2 == 1)
.ToList();
these will become interesting once u start using databases (eg, entity framework) yeah im not sure either same when i declare my own delegates but so far i still stuff them into their own files (unless they r file scoped obviously)
Mayor McCheese
Mayor McCheeseโ€ข2y ago
I usually just pack as many records in a single file as I can reasonably make sense of
cap5lut
cap5lutโ€ข2y ago
but im also comming from the java world, so im used to it ๐Ÿ˜‚
oldcoder
oldcoderOPโ€ข2y ago
that project was (asp.net core mvc razor with ef core + postgres) what a name ๐Ÿ˜„ i didnt learn anything while i was doing that but i learned "what is what"
cap5lut
cap5lutโ€ข2y ago
one day ill take a look at ef core as well ๐Ÿ˜‚ so far ive always written the sql queries myself ;p but yeah, long story short, get started with asp.net ๐Ÿ˜‰
oldcoder
oldcoderOPโ€ข2y ago
it was a vacation to foreign country to me ๐Ÿ˜„ okay one more question about architecture
cap5lut
cap5lutโ€ข2y ago
the only thing that didnt come up yet is async/await, but thats not really a requirement to get started either and tutorials will cover that along the road as well
also it sounds like u have experience with js, so โคด๏ธ should be at least familiar
oldcoder
oldcoderOPโ€ข2y ago
lets say i have a frontend project which finished, and i want to add a backend to it with c# what i need to do yea i have a lot things with async logic so far ๐Ÿ˜„
Pobiega
Pobiegaโ€ข2y ago
dotnet new webapi thats it.
cap5lut
cap5lutโ€ข2y ago
first of all u need to know which end points the front end is calling and which DTOs (data transfer objects) it expects, based on that u can start planning ur controllers and models. but i would suggest that u start with a small simple project at first to get used to asp.net and how to structure it
oldcoder
oldcoderOPโ€ข2y ago
will it be web api or razor mvc i need a backend to connect my frontend lets say a REST CRUD app
cap5lut
cap5lutโ€ข2y ago
well, web api is basically a rest api, so its on u to decide. u can use webapi and simply write a single html file with embedded js for everything or use razor to render the html server side rest is always web api
oldcoder
oldcoderOPโ€ข2y ago
frontend will be js i only need a thing can work itself maybe i could be wrong, i think backend guys writing web api at most cuz there is a frontend which making with js and my goal is being that backend guy which writes backend to a frontend
cap5lut
cap5lutโ€ข2y ago
yeah its often the case that u write web apis, especially if it gets bigger and u have a micro service architecture tho, there is also blazor, then u use c# for front end as well (i never touched blazor, and i think thats for now a bit too advanced for u as well)
oldcoder
oldcoderOPโ€ข2y ago
https://jsonplaceholder.typicode.com/ i mean, when you think API it should give you some routes and data returned from those as i know linkedin api, maps api, yelp etc
Pobiega
Pobiegaโ€ข2y ago
so just make a webapi then
cap5lut
cap5lutโ€ข2y ago
yeah, for those u use api controllers in asp.net ;p (there is also minimal apis, but lets not touch that for now, especially as they are not that useful for most cases)
oldcoder
oldcoderOPโ€ข2y ago
if i didnt have constraints to use js for frontend, i could pick c# for frontend definitely. still do i need to work with mvc, razor or other things except web api
cap5lut
cap5lutโ€ข2y ago
i rly hate GUI programming, why cant everything work via CLI T_T
oldcoder
oldcoderOPโ€ข2y ago
is it enough only learning web api defiinitely agree on that
Pobiega
Pobiegaโ€ข2y ago
I'm a professional C# backend developer, and I do not know MVC or Blazor or MAUI etc ๐Ÿ˜„
cap5lut
cap5lutโ€ข2y ago
well web api is more or less MVC, just that ur view is always json ;p
Pobiega
Pobiegaโ€ข2y ago
I strictly do webapis in all flavors
oldcoder
oldcoderOPโ€ข2y ago
forgive my level, maybe i am asking things not related with my concern
cap5lut
cap5lutโ€ข2y ago
there is nothing to forgive
Pobiega
Pobiegaโ€ข2y ago
I think you should just get started you seem to know what you want
cap5lut
cap5lutโ€ข2y ago
โคด๏ธ
oldcoder
oldcoderOPโ€ข2y ago
yea so far i didnt know what i want
cap5lut
cap5lutโ€ข2y ago
now u do ;p
oldcoder
oldcoderOPโ€ข2y ago
but problem is that command not solving anything ๐Ÿ˜„
Pobiega
Pobiegaโ€ข2y ago
wdym it creates a new webapi project you can then open it up in whatever editor you prefer and you're off to the races
cap5lut
cap5lutโ€ข2y ago
oldcoder
oldcoderOPโ€ข2y ago
๐Ÿ˜‚
[HttpPost]
public async Task<ActionResult<TodoItem>> PostTodoItem(TodoItem todoItem)
{
_context.TodoItems.Add(todoItem);
await _context.SaveChangesAsync();

// return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
return CreatedAtAction(nameof(GetTodoItem), new { id = todoItem.Id }, todoItem);
}
[HttpPost]
public async Task<ActionResult<TodoItem>> PostTodoItem(TodoItem todoItem)
{
_context.TodoItems.Add(todoItem);
await _context.SaveChangesAsync();

// return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
return CreatedAtAction(nameof(GetTodoItem), new { id = todoItem.Id }, todoItem);
}
here show begins i dk asp.net ๐Ÿ˜„
cap5lut
cap5lutโ€ข2y ago
the tutorial is exactly that ;p
Pobiega
Pobiegaโ€ข2y ago
but 90% of that is just normal C#
oldcoder
oldcoderOPโ€ข2y ago
๐Ÿ˜‚ normal C#, yea
Pobiega
Pobiegaโ€ข2y ago
methods, attributes, async/await, return types.. thats all normal C# CreatedAtAction is asp specific, HttpPost is asp specific and ActionResult<T> is asp specific thats it
oldcoder
oldcoderOPโ€ข2y ago
c# tutorials didnt teach me those ๐Ÿ˜‚
cap5lut
cap5lutโ€ข2y ago
work through that tutorial and if u r stuck u can ask on this server for help ๐Ÿ˜‰
Pobiega
Pobiegaโ€ข2y ago
I mean, does your first ever action need to involve a database call? maybe start out with just an endpoint returning "hello world" If I have never cooked food in my life, should the first dish I make be a beef wellington? I've never went out for a jog, lets run a marathon? start small dont dive in at the deep end without knowing how to swim
oldcoder
oldcoderOPโ€ข2y ago
this is my all concern i think starting with web api dont save me
Pobiega
Pobiegaโ€ข2y ago
okay so dotnet new webapi thats all you need to do it creates a default template including an existing simple controller you can look at that and see whats going on then make your own if you have questions, you can ask them but for the love of god, dont expect a tutorial to handfeed you every single bit of information you need
oldcoder
oldcoderOPโ€ข2y ago
no no i m sure everything ll be good when i learn asp.net my concern was how can i add a backend to my frontend
cap5lut
cap5lutโ€ข2y ago
now go, travel and explore the wastelands to find the treasures of knowledge by try and error *heartly send off*
oldcoder
oldcoderOPโ€ข2y ago
and now i know how i only need a thing which exposes routes and gives some data /todos/{id} etc
Pobiega
Pobiegaโ€ข2y ago
thats a controller.
oldcoder
oldcoderOPโ€ข2y ago
yep my view will js i dont need model
Pobiega
Pobiegaโ€ข2y ago
thats fine. its still a controller.
cap5lut
cap5lutโ€ข2y ago
the controller is what wires the front end's requests to the backend's business logic, at least one of these define the api surface
oldcoder
oldcoderOPโ€ข2y ago
totally what you guys think about connecting next.js with asp.net core
Pobiega
Pobiegaโ€ข2y ago
probably fine. will need a reverse proxy thou?
cap5lut
cap5lutโ€ข2y ago
i have barely any knowledge about vanilla js, so i cant say anything about that
Pobiega
Pobiegaโ€ข2y ago
since next.js includes SSR stuff
oldcoder
oldcoderOPโ€ข2y ago
i dont even know my plan is connecting my backend to next but i dk its doable or forbidden
Pobiega
Pobiegaโ€ข2y ago
doable, not forbidden
cap5lut
cap5lutโ€ข2y ago
get started and think about it later ;p
oldcoder
oldcoderOPโ€ข2y ago
today i learned 3 things with your great help - asp.net is advanced c# and has specific features like classes, interfaces etc - i need to play well with c# before jumping to web - for beginning i only need a web api with only controllers returning some dummy data, but for WEB API concept, first i need to learn asp.net at a good level
Pobiega
Pobiegaโ€ข2y ago
asp.net is advanced c# and has specific features like classes, interfaces etc i need to play well with c# before jumping to web
this is like the opposite of what we said but okay
oldcoder
oldcoderOPโ€ข2y ago
you said you can play with asp.net as you know c# but i realized my c# is not enough to play with asp.net yet
Pobiega
Pobiegaโ€ข2y ago
its not advanced C# thou, and "classes and interfaces" are not unique to asp lol they are FUNDAMENTAL core concepts of C# in general
oldcoder
oldcoderOPโ€ข2y ago
i mean async, linq, ef
Pobiega
Pobiegaโ€ข2y ago
thats also general C# stuff none of it is asp specific
oldcoder
oldcoderOPโ€ข2y ago
i dk why but i didnt learn those
Pobiega
Pobiegaโ€ข2y ago
because you did a "introduction to C#" course
oldcoder
oldcoderOPโ€ข2y ago
ah yes
Pobiega
Pobiegaโ€ข2y ago
it wont introduce everything in a fairly large language
oldcoder
oldcoderOPโ€ข2y ago
i think i need to finish 201 before maybe more
Pobiega
Pobiegaโ€ข2y ago
not really you can learn all of that as you go its not a requirement to get started
oldcoder
oldcoderOPโ€ข2y ago
cuz this looks like a thing which i cant understand properly
[Fact]
public void GetShouldThrowExceptionIfUserIsDeleted()
{
var expense = new Expense { Id = _random.Next(), UserId = _currentUser.Id, IsDeleted = true};
_expenseList.Add(expense);

Action get = () =>
{
_query.Get(expense.Id);
};

get.ShouldThrow<NotFoundException>();
}
[Fact]
public void GetShouldThrowExceptionIfUserIsDeleted()
{
var expense = new Expense { Id = _random.Next(), UserId = _currentUser.Id, IsDeleted = true};
_expenseList.Add(expense);

Action get = () =>
{
_query.Get(expense.Id);
};

get.ShouldThrow<NotFoundException>();
}
Pobiega
Pobiegaโ€ข2y ago
thats a unittest lol
oldcoder
oldcoderOPโ€ข2y ago
i can read, understand but with my TS knowledge ๐Ÿ˜„ first i ll learn C# things thanks guys especially your patience and time (tho its a default thing when dealing with c# lol ) ๐Ÿ˜‚ but i didnt get one thing do i need a DB or sth to make a web api examples saying yes, but i dont know how to work with DB
Pobiega
Pobiegaโ€ข2y ago
no, but it wont be a very useful api without one
oldcoder
oldcoderOPโ€ข2y ago
oldcoder
oldcoderOPโ€ข2y ago
looks like i have to deal with console apps again ๐Ÿ˜‚
Pobiega
Pobiegaโ€ข2y ago
why?
Pobiega
Pobiegaโ€ข2y ago
dont follow that lol it recommends fiddler ๐Ÿ˜„
oldcoder
oldcoderOPโ€ข2y ago
i dont even know what is fiddler ๐Ÿ˜„ actually i wouldnt ask this question at all
Pobiega
Pobiegaโ€ข2y ago
its a bit like postman except its a mitm
oldcoder
oldcoderOPโ€ข2y ago
okay i wanna ask you honest question then i ll disappear lets say you want to test a route ex: localhost:5000/api/test and it ll only return a string or json one route, you ll make a curl to it, and it gives you result what would be your "minimal, painless" way to achieve it ๐Ÿ˜„ for ease it only includes GET one function, one controller
Pobiega
Pobiegaโ€ข2y ago
sure wgimmie 1 sec, healing a dungeon :d
oldcoder
oldcoderOPโ€ข2y ago
wow
Pobiega
Pobiegaโ€ข2y ago
in fact, do you wanna watch me do it live? the api
oldcoder
oldcoderOPโ€ข2y ago
no i only need way like a food recipe chop, cook, serve it doesnt have to be extensive or detailed like this From the File menu, select New > Project. Enter Web API in the search box. Select the ASP.NET Core Web API template and select Next. but not that detailed start a new template, delete redundant stuff, edit here like that and done
Pobiega
Pobiegaโ€ข2y ago
im not doing that lol dotnet new webapi remove weatherforecast controller and its model create a new controller done
using Microsoft.AspNetCore.Mvc;

namespace BrandNewApi.Controllers;

[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
[HttpGet]
public string Index()
{
return "Hello world";
}
}
using Microsoft.AspNetCore.Mvc;

namespace BrandNewApi.Controllers;

[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
[HttpGet]
public string Index()
{
return "Hello world";
}
}
this is my controller
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
this is my "Program.cs" thats it all the code in the entire project I didnt write a single line in program.cs, thats the default
oldcoder
oldcoderOPโ€ข2y ago
hmm
Pobiega
Pobiegaโ€ข2y ago
and look
Pobiega
Pobiegaโ€ข2y ago
Pobiega
Pobiegaโ€ข2y ago
it comes with swagger by default
oldcoder
oldcoderOPโ€ข2y ago
awesome my pain was "learning C# to reach a level which i can do that easily"
Pobiega
Pobiegaโ€ข2y ago
[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
[HttpGet]
public string Index()
{
return "Hello world";
}
}
[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
[HttpGet]
public string Index()
{
return "Hello world";
}
}
was all I wrote myself. I could have looked at the example controller and copied the attributes from there
oldcoder
oldcoderOPโ€ข2y ago
i am sure you are getting me maybe i am looking that so noob ๐Ÿ˜„ if you want "write another route which accepts post request with id" from me i cant when i look that i only see that for now
public class TestController : ControllerBase // what is the type of ControllerBase (abstract or normal) etc
{
public string Index()
{
return "Hello world";
}
// ? why not override for ex ?
public override string Another()
{
return "another"
}
}
public class TestController : ControllerBase // what is the type of ControllerBase (abstract or normal) etc
{
public string Index()
{
return "Hello world";
}
// ? why not override for ex ?
public override string Another()
{
return "another"
}
}
got it
Pobiega
Pobiegaโ€ข2y ago
Pobiega
Pobiegaโ€ข2y ago
[HttpPost]
public string Post(int id)
{
return $"{id}";
}
[HttpPost]
public string Post(int id)
{
return $"{id}";
}
oldcoder
oldcoderOPโ€ข2y ago
i saw a thing like public IActionResult Index() { return View() }
Pobiega
Pobiegaโ€ข2y ago
View() is for MVC controllers
oldcoder
oldcoderOPโ€ข2y ago
i am feeling i got what i want and keepin you busy still ๐Ÿ˜„
Pobiega
Pobiegaโ€ข2y ago
this is an api controller, it doesnt have views
oldcoder
oldcoderOPโ€ข2y ago
dont get me wrong
Pobiega
Pobiegaโ€ข2y ago
can also do stuff like
[HttpPost]
public MyResponseModel Post(int id)
{
return new MyResponseModel()
{
Id = id,
RandomGuid = Guid.NewGuid(),
};
}
[HttpPost]
public MyResponseModel Post(int id)
{
return new MyResponseModel()
{
Id = id,
RandomGuid = Guid.NewGuid(),
};
}
public class MyResponseModel
{
public int Id { get; set; }
public Guid RandomGuid { get; set; }
}
public class MyResponseModel
{
public int Id { get; set; }
public Guid RandomGuid { get; set; }
}
oldcoder
oldcoderOPโ€ข2y ago
i can read and understand this syntax
Pobiega
Pobiegaโ€ข2y ago
Pobiega
Pobiegaโ€ข2y ago
looks like this when called yeah, and this is what a simple webapi looks like the examples you showed were all for more complicated setups with databases and async code and yes, you will need to learn that eventually but to start, you dont
oldcoder
oldcoderOPโ€ข2y ago
hmm this changes everything lets look at this code
// DELETE: api/TodoItems/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);
if (todoItem == null)
{
return NotFound();
}

_context.TodoItems.Remove(todoItem);
await _context.SaveChangesAsync();

return NoContent();
}
// DELETE: api/TodoItems/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);
if (todoItem == null)
{
return NotFound();
}

_context.TodoItems.Remove(todoItem);
await _context.SaveChangesAsync();

return NoContent();
}
from microsoft tutorial i cant read this with my current knowledge why Task<IActionResult> is it default, or variable say i can write Task<MyClass> etc maybe its related with i know c# but not asp.net i can understand what it is doing, but i dk how to write that
Pobiega
Pobiegaโ€ข2y ago
so Task, async and await are all related to async code Task is like Promise from js/ts IActionResult is an untyped http response it lets us return 204 or 404 or any other http code my code above only ever returned 200 or 500
oldcoder
oldcoderOPโ€ข2y ago
[ValidateAntiForgeryToken] ๐Ÿ˜„ but am not asking that its okay eventually most apps require auth layer its better to finish that 201 lessons asap then i ll start to learn asp.net with its own tutorials thankfully microsoft thought this already because of i am not good at "backend logic" and c#, things being complex to me but its okay i can handle this when i learn
var movies = [{id: 101, name: "Fight Club", year: 1999, rating: 8.1}];
router.get('/', (req, res) => { res.json(movies); });
var movies = [{id: 101, name: "Fight Club", year: 1999, rating: 8.1}];
router.get('/', (req, res) => { res.json(movies); });
๐Ÿ˜‚ thanks again, i enjoyed besides learning
Pobiega
Pobiegaโ€ข2y ago
[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
private static List<Movie> _movies = new List<Movie>()
{
new(101, "Fight Club", 1999, 8.1f),
new(102, "Inception", 2010, 8.7f),
new(103, "The Dark Knight", 2008, 9f),
new(104, "12 Angry Men", 1957, 8.9f),
};

[HttpGet]
public IEnumerable<Movie> Index()
{
return _movies;
}
}

public record Movie(int Id, string Name, int Year, float Rating);
[ApiController]
[Route("[controller]")]
public sealed class TestController : ControllerBase
{
private static List<Movie> _movies = new List<Movie>()
{
new(101, "Fight Club", 1999, 8.1f),
new(102, "Inception", 2010, 8.7f),
new(103, "The Dark Knight", 2008, 9f),
new(104, "12 Angry Men", 1957, 8.9f),
};

[HttpGet]
public IEnumerable<Movie> Index()
{
return _movies;
}
}

public record Movie(int Id, string Name, int Year, float Rating);
not that different :p
oldcoder
oldcoderOPโ€ข2y ago
like "god why" right
Pobiega
Pobiegaโ€ข2y ago
its just that C# doesnt do anonymous types, so we declare a Movie type
oldcoder
oldcoderOPโ€ข2y ago
life is so weird right but i can say this "even c# looks more complex, still writing it gives confidence and enjoy" Type thing = new Type(); feels me like carving onto stone ๐Ÿ˜‚ explaining it to 5 have you worked with TS @pobiega
Pobiega
Pobiegaโ€ข2y ago
yup.
oldcoder
oldcoderOPโ€ข2y ago
i realized its more extended than c#
Pobiega
Pobiegaโ€ข2y ago
"extended"?
oldcoder
oldcoderOPโ€ข2y ago
so far i was thinking c# is harder than ts
Pobiega
Pobiegaโ€ข2y ago
the TS typesystem is crazy to be honest, but it has to be since it tries to support javascript but it has a lot of nice things, like discriminated unions
oldcoder
oldcoderOPโ€ข2y ago
the inventor of both saying same i made a monster ๐Ÿ˜„
Pobiega
Pobiegaโ€ข2y ago
the inventor of TS is the same guy who made C# you know that right?
oldcoder
oldcoderOPโ€ข2y ago
yep one side people inventing 3 languages other side i am trying to understand its type systems ๐Ÿ˜‚ wish people can use TS for backend
Pobiega
Pobiegaโ€ข2y ago
uhm you can thats what I used it for.
oldcoder
oldcoderOPโ€ข2y ago
cuz now i am forcing myself to learn C#, even i know TS in my country most of companies working with C# at backend so i have to learn it anyways accept my apologies to ruin your day with my questions hope i can ask questions related with code after some time good luck
cap5lut
cap5lutโ€ข2y ago
back (sry had to water the plants and feed the animals) so any questions left to answer or r u set for ur journey?
oldcoder
oldcoderOPโ€ข2y ago
wish people can use TS for backend we re here if i know well, i could write a thing like asp.net but TS to favor of humanity but unfortunately TS is not popular like C# when it comes backend i cant edit that
oldcoder
oldcoderOPโ€ข2y ago
cap5lut
cap5lutโ€ข2y ago
wow php is still that widely used, didnt expect that, but i guess that also includes the small "home pages" with not too much functionality
Pobiega
Pobiegaโ€ข2y ago
bingo
i guess that also includes the small "home pages"
cap5lut
cap5lutโ€ข2y ago
my first steps in web dev were in php, but that was back in 2005 or so ๐Ÿ˜‚
Pobiega
Pobiegaโ€ข2y ago
PHP is trivial to host thats a huuuuuuuge part of why its so big
cap5lut
cap5lutโ€ข2y ago
yeah, free php + mysql hosting (with some ads on it) was a thing back then. ofc i used some js and css to get rid of the ads xD
oldcoder
oldcoderOPโ€ข2y ago
cap5lut
cap5lutโ€ข2y ago
i wrote a lil calendar app back then where my class mates and me could upload the home work ๐Ÿ˜„
oldcoder
oldcoderOPโ€ข2y ago
oldcoder
oldcoderOPโ€ข2y ago
when i look that 3 graph, i want to ran away from coding
Pobiega
Pobiegaโ€ข2y ago
.. okay? Feel free to. I hope noone is forcing you to code against your will
cap5lut
cap5lutโ€ข2y ago
i doubt these charts r correct esepecially the cobol thingy
oldcoder
oldcoderOPโ€ข2y ago
most popular stack is looking like MERN but when i look at first one, it becomes C#
Pobiega
Pobiegaโ€ข2y ago
good cobol devs make like.. 3 times what other devs make here since there is like 12 of them in the entire country
oldcoder
oldcoderOPโ€ข2y ago
when it comes salary TS devs more than C#
cap5lut
cap5lutโ€ข2y ago
yeah, because there r like 3 cobol experts left in the world ๐Ÿ˜‚
Pobiega
Pobiegaโ€ข2y ago
I highly doubt that also, where the fuck are these numbers from?
oldcoder
oldcoderOPโ€ข2y ago
stackoverflow
cap5lut
cap5lutโ€ข2y ago
do u have a link?
Pobiega
Pobiegaโ€ข2y ago
so its an average and in the SO surveys, you pick multiple languages ie, I can say I'm a TS/C# dev
oldcoder
oldcoderOPโ€ข2y ago
Stack Overflow
Stack Overflow Developer Survey 2023
In May 2023 over 90,000 developers responded to our annual survey about how they learn and level up, which tools they're using, and which ones they want.
Pobiega
Pobiegaโ€ข2y ago
and I guess my salary contributes to both averages
cap5lut
cap5lutโ€ข2y ago
also dont forget that c#/asp.net is still on quite a stable rise, it hasnt been long since it went xplat
oldcoder
oldcoderOPโ€ข2y ago
i want to believe i am doing good with learning C#
cap5lut
cap5lutโ€ข2y ago
u do
oldcoder
oldcoderOPโ€ข2y ago
but also have a feeling why i am not going with js
Pobiega
Pobiegaโ€ข2y ago
its not a mutually exclusive choice most people know and use multiple languages I personally use primarily C#, but I also use TS, Rust, F# and Kotlin
cap5lut
cap5lutโ€ข2y ago
after some time it doesnt really matter. once u understand how the interna works, its more about learning the language specific quirks and their bcl/stdlib/whatever they call it in that language in my life i touched c, c++, pascal, java, kotlin, c#, rust, python, php, i think im missing some oh groovy as well but that was mainly for gradle scripts js too
Pobiega
Pobiegaโ€ข2y ago
VB, PHP, C#, ActionScript, C, C++, java, D, JS, python here, in addition to what I mentioned above. and some shorter experiments with stuff like haskell, scala, ocaml
cap5lut
cap5lutโ€ข2y ago
TS i never touched but thats mainly because i stopped my minimalistic front end crap
Pobiega
Pobiegaโ€ข2y ago
https://danielyxie.github.io/bitburner/ is my primary usecase for TS lately ๐Ÿ˜„
cap5lut
cap5lutโ€ข2y ago
most of the languages i mainly tried back then for a chat bot system for a mmorpg because i wanted updates to plugins during runtime and platform independent, i started with java and did quite a round trip to end up with java (OSGi framework) again. still thinking about writing it in c# but instead with a micro service architecture xD but the game is dead any way (its release was in 2001)
Pobiega
Pobiegaโ€ข2y ago
2001... its not Dark Age of Camelot is it? that game didnt have plugins for aaaages. but thats actually the reason I went into C#
cap5lut
cap5lutโ€ข2y ago
Anarchy Online from Funcom
Pobiega
Pobiegaโ€ข2y ago
the first OSS server emulator for DAoC was in C# oooh, AO. Nice.
cap5lut
cap5lutโ€ข2y ago
i stopped playing last year, but there i was already multi boxing (playing with 6 accounts simultanously) to help the community get some raids done there r like 100 ppl max online at the same time, so its more or less going down and FC didnt even care about exploiters that used item duping etc the multi box wasnt really a concern for them as u still had to pay for each account (~110โ‚ฌ per year per acc) we... should take this somewhere else xD
Pobiega
Pobiegaโ€ข2y ago
;D
cap5lut
cap5lutโ€ข2y ago
actually im going to play some osu for now, unless i find something interesting in the other channels
Accord
Accordโ€ข2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server