Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have little trouble with moving java variable to c#
This is the code in java:

Java
private final VisibleObjectController< ? extends VisibleObject > controller;


i want to do the same in c#.

What I have tried:

i tried
C#
private VisibleObjectController< T > where T : VisibleObject controller;


but sure its not work, error syntax
Posted
Updated 30-Nov-16 22:29pm

You can't use a constraint on a private field (or property) only on the class or interface
C#
public class MyCLass<t> : where T : VisibleObject 
{ 
   private VisibleObjectController<T> controller;
}
</t>
 
Share this answer
 
Comments
EADever 1-Dec-16 4:24am    
So in c# can't do like Java? :(
Coz I need that variable inside a normal class without extends T
This is the same question as How do I do the same java extends class in C#?[^], and you have already been given the answer. Please do not repost; if you have information to add then edit the original question.
 
Share this answer
 
Comments
EADever 1-Dec-16 4:31am    
Thanks sir. But I don't have correct answer yet :(
Richard MacCutchan 1-Dec-16 4:40am    
Then go back to the original question and reply to the person who gave you a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900