All Questions
407
questions
-1
votes
2
answers
79
views
Is there a way to make a class with no limit on the number of Generic Type Parameters in c#? [duplicate]
I am working on a project in which I need to define any number of possible parameters when creating an object.
public class base
{
//Variable Declarations here...
public base(){ //Handle ...
0
votes
2
answers
52
views
How to check that there are no duplicates in an array? [duplicate]
I'm writing an application in C# that prompts the user for data for objects of an Automobile class. One of the properties of the class for which the program prompts the user for data is ID number. If ...
-1
votes
3
answers
85
views
Reading object value from other class in C#
I always have coded in C++ but I am learning C# now. I got a trouble with accessing the object value.
Here is what I tried.
class Program
{
static void Main(string[] args)
{
...
1
vote
3
answers
122
views
Using the object value in the class in C# [closed]
I always have coded in C++, but now trying to learn C#. I was trying to create multiple objects and use data of them in C#. However, it does not work in the way I desire.
Here is the code I tried.
...
1
vote
1
answer
69
views
Access nested members in custom Settings-Class
I thought I had fully understood classes in C#, but atm I'm trying to create a custom Settings-Class for a Project of mine, but I just can't get it right.
What I want to achieve:
Have a class which ...
4
votes
2
answers
276
views
Difference between new() and new class() C#
What is the difference between new() and new class() because it seems that both run with no difference.
Human John = new();
or
Human John = new Human();
Let's say in this context it does not make ...
0
votes
1
answer
25
views
C# Trying to use a method to assign attributes of an old object to new objects
I'm new to c# and programing in general, like a few weeks, and this has stumped me. The code below is the one I'm having trouble with.
internal class Program
{
static void Main(string[] ...
1
vote
1
answer
240
views
How can I read the name of a thread in a C# application?
I'm working on a multithreaded application, written in C#.
I would like to verify if a thread is already running or not.
You might think "How easy can that be?", but there seems to be a ...
2
votes
2
answers
279
views
Getting all values of properties of an object into an array in c#
Im trying to get all the field values of an object into an array. but the problem is the fields of the object can have other types rather than string but ultimately all the values should be a string.
...
0
votes
0
answers
131
views
(C#) How can I access a property of the parent class?
I want to access a property of my master object.
Here, after instantiating the class City, I want to know the country this city belongs to.
public class Country
{
public string NameOfCountry { get;...
0
votes
3
answers
115
views
Converting a C# class I created inside a project to a separate reusable class
I'm not new to C# programming, but I suppose I'm new to programing "the right way" in C#. I've worked in C on embedded devices for years and have written desktop apps to support them. First ...
-4
votes
1
answer
79
views
making instance of class in c# [closed]
In this code
using System;
namespace Hello
{
class TestEmployee
{
static void Main()
{
Employee employee = new Employee();
employee.salary = 1000;
...
-1
votes
2
answers
400
views
How can I match a specific existing object by a string property?
I am trying to make a query system for objects, but I have been unable to figure out how to turn a string from Console.ReadLine() to an object's name. Here is an example code snippet:
class Program
{
...
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 ...
0
votes
1
answer
94
views
C# - Object without '= new Kid()'
Goodmorning.
How is it possible at the line 28 and 29 the kd has the ability to use the property and the function without using 'Kid kd = new Kid();' at the line 24.
Normally i get the error at the ...