C
C#

help

✅ how to move it to abstract class

SDSam DZ12/26/2022
I want to move admin user name & adminpass to abstract class or method The point is how to compare them to user input after that
BBecquerel12/26/2022
Why do you want to make it abstract?
SDSam DZ12/26/2022
Just because the Dr. In college want that lol 💔 @Becquerel
BBecquerel12/26/2022
PepeHands professors the way you would do it is like this
public abstract class Login
{
void Login();
}

public class AdminLogin : Login
{
public void override Login()
{
// same as what you already have, including user input
}
}

public class UserLogin : Login
{
public void override Login()
{
// you can do this differently than in the AdminLogin class, assuming that users login differently to admins
}
}
public abstract class Login
{
void Login();
}

public class AdminLogin : Login
{
public void override Login()
{
// same as what you already have, including user input
}
}

public class UserLogin : Login
{
public void override Login()
{
// you can do this differently than in the AdminLogin class, assuming that users login differently to admins
}
}
this lets you do this:
var logins = new List<Login>();

// We can treat both classes as if they were the same and put them in the same list.
logins.Add(new AdminLogin());
logins.Add(new UserLogin());

// Because we can treat both classes as if they are the same, we can call the methods common to both of them - the methods in the abstract class
foreach (var login in logins)
{
login.Login();
}
var logins = new List<Login>();

// We can treat both classes as if they were the same and put them in the same list.
logins.Add(new AdminLogin());
logins.Add(new UserLogin());

// Because we can treat both classes as if they are the same, we can call the methods common to both of them - the methods in the abstract class
foreach (var login in logins)
{
login.Login();
}
Mmtreit12/26/2022
As an aside, let's talk about using a string to control your loop...
SDSam DZ12/26/2022
@mtreit What you want to talk about it? @Becquerel
I'm going to try it
Mmtreit12/26/2022
Use a boolean value directly
SDSam DZ12/26/2022
I found this easier You can call me Baby junior 😂😎 @mtreit
Mmtreit12/26/2022
Yes?
SDSam DZ12/26/2022
Any content creator or book recommendations for be better in c# i will appreciate it 🙌🏻 @mtreit
Mmtreit12/26/2022
Have you done $helloworld ?
SDSam DZ12/26/2022
@mtreit I'm doing my first oop for college So i get a step forward in base ideas
Mmtreit12/26/2022
The interactive course I linked is a good place to start to get familiar with C# as a language
SDSam DZ12/26/2022
@Becquerel I didn't know how to do it It gives me many errors
BBecquerel12/26/2022
i don't know what those errors are

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ ✅ Applying math to programmingHi, this is not necessarily a C# question and more question towards math and programming. I am using❔ Blazor webassembly app hosted ASP.NET Core 7 test with WebApplicationFactoryI have a Blazor webassembly app hosted in ASP.NET Core 7 that I want to run some tests on. I'm tryi❔ Output informationI have two constructors that take a surname or surname and a collection with salaries . How can I ge❔ 2 Errors in image downloadingMy code: ```cs private void button11_Click(object sender, EventArgs e) { saveFil✅ write multiple Lists to fileI want to write several items from lists that have same index to text file, what is the easiest way❔ Poor DataGrid performance when using DataTableI'm writing a program that can take any number of different tab delimited csv files, load them into ❔ CSharp Socket Stream StacksThe stream buffer stacks data, instead of receiving, processing, repeating loop. ```csharp ❔ xmlhow to make to my program reads only elements inside "Officer I"?❔ hey i need guidance from a .net expertplease❔ reverse of RemoveAt[index]hi, so my problem is that im itterating through a list of 10 questions, and each time the user has cSome namespace and class questions..```css namespace Cool { class VeryCool { static void main(string[] args) { ✅ Texas holdem pokerHi, I need help with my project to school. My task is to create Texas holdem poker. But I dont know ❔ Sockets - TCPI'm going to implement a TCP listener for RF-V48 (4G GPS Tracking Bracelet) for elders. The device i❔ Problems with colliders...Context: when a game object with tag "Player" touch other object, print in console "Func". But that ❔ .NET6 Selenium 4. it’s possible to use Navigate.GoToUrl(url) using http Post?Hi, Im was searching around a solution or approach for use a POST method instead GET when using GoTo❔ Multi-tenant == Roles ?I need clarification whether the RoleManager in IdentityDbContext that manages roles for user author❔ Custom template not showing upI'm trying to create a new custom .csproj template for .NET 7, but I can not seem to get it to show ❔ Is it possible to put a method into a variable and call the variable?like this:❔ Getting error 500 on form post (using fetch)I'm trying to do a form post (posting a model), but my controller is not being called. When I check❔ Need some help with logicim trying to make a the total defence and attack statistics equal to 35 (they are randomised for 6 p