All Questions
106
questions
-3
votes
1
answer
58
views
How to modify the object (textBox) that called the method from within the method itself?
EDIT: This question has been solved using "sender" (see answer below)--thank you to everyone who left comments!
I'm trying to create a method that I can call within any number of text fields ...
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
373
views
How to make a method, that accepts an input, into a property of a class object?
The issue I've encountered here, is that I am currently trying to make an object that has a method as a property. I was able to get it to work on public static void methods, but not methods that ...
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
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
vote
2
answers
40
views
C#: Is there a way to return a side by side array with commas after what you input on a list on the console window from top to bottom?
I am new to C#. This is my code. When I run this code, I input the car name, mileage, year, make, model, color, and bodytype to a list that looks like this
Name of Car: Car 1
Enter Mileage: 4000 (my ...
0
votes
1
answer
705
views
"Stack overflow. Repeat 261929 times[...]" is the error message when I have debugged my code then I do not see any issues so what should I do?
I have coded every line with appropriate things, however, I received an error when I tested after selecting one of the five options from the menu which is prompting the user to choose it for register ...
0
votes
0
answers
50
views
Access a form's methods from other forms
I have a main form, called frmContainer. with two panels, a pnlTitle (holding the title) and a pnlMain. Multiple other forms get loaded into pnlMain. frmContainer.cs has multiple methods which load ...
-2
votes
1
answer
275
views
what is the order of execution of the following C# code?
In the following code I change a StringBuilder object contect in two diffrent ways .
Does the Shorter code calls and execute the StringBuilder methods in the same order ?
static void ...
0
votes
2
answers
61
views
How do I return a list with newly added objects from a method (Beginner) C#
I am having trouble returning a list from a method called "omvandlaBetyg" which translates to "convert grades". I have added a total of 5 'char' to my list. I wish to return the ...
-1
votes
2
answers
1k
views
C# how to refer to objects inside a method
So i need to create a class called "store" in this class i need to have a method called "start", now in said method i need to create 9 objects from different classes. I then need ...
-2
votes
1
answer
60
views
C# - understanding Objects, Classes, and Method interactions
Very, very new programmer here facing some big troubles, I am trying to achieve as follows:
I want to write a very basic program in which the user is prompted to input two double variables, I then ...
0
votes
1
answer
40
views
C# Detect the object sent to the generics class and start processing
Im sorry for my bad english. There is a problem that I cannot solve because I am new to generics.
When the constructor method is running, How can I detect the incoming class. I have to continue the ...
1
vote
1
answer
167
views
Show method only under certain conditions
I created a .net extension method that converts an string to an integer and throws an InvalidCastException if the passed string isn't an integer:
public static int ToInt32(this String str)
{
...
0
votes
0
answers
142
views
Array holds multiple objects of different classes, how can I call the coresponding method?
I'd like to apologize in advance for the amount of text that follows. I am learning C# and really got stuck on a task thats probably trivial to advanced users, but searching the internet has brought ...