Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3243024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:23:03+00:00 2026-05-17T18:23:03+00:00

Hello fellow stackoverflow members! I’m very new to the C# language transfer from Java,

  • 0

Hello fellow stackoverflow members!

I’m very new to the C# language transfer from Java, Obj-C.
It looks pretty same as Java, but I have trouble issue in very simple thing.
I have created two individual class files, Class-A and Class-Human.

Specification for Class-A

it contains the static main method declared.And I’ve tried to create the new instance of Class-Human.

public static void main(String args[])
{
      Human human = new Human("Yoon Lee", 99);
      int expected = human.getNetID; //<-gets the error at this moment.
}

Specification for Class-Human

namespace Class-A
{
    public class Human
    {
        public String name;
        public int netId;

        public Human(String name, int netId)
        {
            this.name = name;
            this.netId = netId;
        }
     public int getNetID()
     {
         return netId;
     }
}     

Why can’t copy over into local variable?
The compiler prompts me the error of

'Cannot convert method group of 'getNetID' delegate blah blah'

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:23:03+00:00Added an answer on May 17, 2026 at 6:23 pm

    Change the method-call to:

    int expected = human.getNetID();
    

    In C#, method-calls require parantheses () containing a comma-separated list of arguments. In this case, the getNetID method is parameterless; but the empty parantheses are still required to indicate that your intention is to invoke the method (as opposed to, for example, converting the method-group to a delegate-type).

    Additionally, as others have pointed out, there is a mismatch betweem the return-type of the method and the variable you’re assigning its value to, which you’re going to have to resolve somehow (change both the field-type and method return-type to int / parse the string as an integer, etc.).

    On another note, C# natively supports properties for getter-setter semantics, so the idiomatic way of writing this would be something like:

    //hyphens are not valid in identifiers
    namespace ClassA
    {
        public class Human
        {
            // these properties are publicly gettable but can only be set privately
            public string Name { get; private set; } 
            public int NetId { get; private set; }
    
            public Human(string name, int netId)
            {
                this.Name = name;
                this.NetId = netId;
            }
    
            // unlike Java, the entry-point Main method begins with a capital 'M'
            public static void Main(string[] args)
            {
                Human human = new Human("Yoon Lee", 99);
                int expected = human.NetId; // parantheses not required for property-getter
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow stackoverflow family members? I know it is un-efficient to create one extra
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello fellow StackOverflow users (or Stackoverflowers ?): I'm learning-by-coding WPF. I read several articles/saw
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello there and Merry Christmas !!! I am new to WPF and I am
Hello fellow coders & codetts I was wondering, if I needed to create a
Hello there fellow Stackers! I wonder if anybody could tell me what the following
Hello again stackoverflow... Once again I have a troublesome problem. I have a page
Hello my fellow stackoverflower, i'm looking for away to smooth an image of and
Hello fellow C++ programmers. I have, what I hope to be, a quick question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.