0

I tried to convert my Java code in C# but I missed something.

Java code

  public Map<String, MyDataClass> getData() {
        return data;
    }

    public void setDataCarriers(Map<String, MyDataClass> data) {
        this.data = data;
    }

Which is converted by tool like following:

public virtual IDictionary<string, MyDataClass> Data
        {
            get
            {
                return data;
            }
            set
            {
                this.data = value;
            }
        }

but getting error:

Using the generic type 'MyDataClass' requires 1 type arguments

Java code

public class MyDataClass<T> implements Serializable {

    private T demohere;

    public T get() {
        return demohere;
    }

    public void set(T demohere) {
        this.demohere= demohere;
    }
 }

Converted to C#

 [Serializable]
    public class MyDataClass<T>
    {
        private T demohere;
        
        public virtual T demohere
        {
            get
            {
                return demohere;
            }
            set
            {
                this.demohere= value;
            }
        }
    }

1 Answer 1

2

You should change type of Data to IDictionary<String, MyDataClass> and remove type argument <T> from MyDataClass

Sign up to request clarification or add additional context in comments.

6 Comments

@Neo remove type argument <T> from MyDataClass definition. As I can see, in your Java code this class is not generic.
@Neo please next times add full code snippets related to the question.
@Neo so now I can say, that you should now insert back type argument with type you want to use, like <string> or <object> or whatever you need.
sorry for the inconvenience
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.