All Questions
199
questions
0
votes
3
answers
87
views
How to assign a property to a value depending on the value of a different property when returning a new object C#?
I have a project in C#. I have the following class:
public class MyClass
{
public int Id { get; set; }
public string Info { get; set; }
public string Name { get; set; }
}
Then, in one of ...
0
votes
1
answer
54
views
A property in Child Object in Parent Object-A is changed when a new property in Child Object in Parent Object-B is added
Consider this object
{
"ClassId": 101,
"Sections": [
{
"SectionId": 201,
"Subjects": [
{
...
1
vote
1
answer
98
views
Creating child classes that only inherit parents data once
Currently I'm trying to create some attribute let's call it "DoNotShareWithGrandChildren" that will be used by the highest level parent class but not the children classes below it. The issue ...
0
votes
0
answers
35
views
Cannot validate properly the username and password using Array.Find()
I'm trying to make a username and login system to validate if the username and password passed by an user by input matches the username and password in an array of objects. I did using Array.Find() ...
-1
votes
4
answers
90
views
Accessing the variables of an object using the object type in C#
assuming I have a base class called AnimalTypes and 3 derived classes, all 4 containing only variables. What I want to do is to create a List or an Observable collection in which I can add any type of ...
-1
votes
1
answer
198
views
How to display details from an object to a TextBox
I am making a program which will test if an airplane is allowed to fly or not. It's my very first personal project using Windows Form and C#. I made a lot of progress, however, I am having a huge ...
1
vote
1
answer
535
views
c# Create a class with a method that outputs title and author, create objects and call the method
This is an assignment I have in c#:
"Create a class called Book that defines attributes Title, Author, and Year. Add a method called Display() that outputs the Title and Author. Demonstrate ...
-1
votes
1
answer
60
views
Is there a way to pull specific child class from a parent class object variable?
I have a Room class which holds a Mob object. A Mob object can either be of type Passive or of type Hostile and each have their own specific behavior. These Mob objects will move around from Room to ...
0
votes
0
answers
34
views
How to copy/reference an object and updating values in a Linked List
I'm trying to understand how copy/reference works in the algorithm below to solve LeetCode's 'Merge Two Sorted Lists' problem.
This algorithm uses the iteration approach to merge the linked lists, ...
0
votes
2
answers
57
views
Converting objects to Subclass
I want to make a class Vehicle and two classes (PassengerVehicle and FreightVehicle) that inherit it. The problem is that when the user enters the type of vehicle he wants and when I convert an object ...
1
vote
1
answer
54
views
C#/WPF - IsElement as a class property/attribute?
I am trying to remake my C#/WPF take on the Simon game by making it more clean and use classes now that I finally understand classes. Before I ask my question - here is some sample code from my old ...
0
votes
2
answers
85
views
Error on implementing an Interface using interface typecasting
I have a few interfaces that are
public interface ISaleOrderManager
{
Task<IOrderDto> CreateAsync(ICreateOrderDto request);
}
public interface ICreateOrderDto
{
long? ContactId { get; ...
1
vote
1
answer
144
views
How to assign a value to class member from another form in C#?
I have 2 form .First one is Form1 and the second is Form2. And also i have a class in Form1 which name is Matrix.
public class Matris
{
public int city;
public int country;
};
...
-2
votes
1
answer
188
views
Create object using user input in C# [duplicate]
I would like to use a string from user input as the name of a new object.
This is where i'm currently at:
string newMemberName = "";
Human Mihkel = new Human("Mihkel", 1); //...
3
votes
1
answer
314
views
C# Is there a way to make the properties of an object in a class non-editable outside the class itself?
I am looking for a way to have an object in a class and make it non-editable (the object itself AND its properties) outside the class itself but still visible outside.
internal class Room
{
public ...