Class inheritance in Unity / C#?

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Post Reply
sushant015
Posts: 1
Joined: 21 Dec 2017, 09:11

Class inheritance in Unity / C#?

Post by sushant015 »

Hi,

I have two classes on server side JAVA code , one is base class [Class A] and second [Class B] is child class. Both classes are in same namespace. Code are below :-

Code: Select all


public class A implements SerializableSFSType{
	public int a =0;
	public A(){}
	public int getA() {
		return bountyCount;
	}
	
	public void setA(int a) {
		this.a = a;
	}
	
}
public class B extends A implements SerializableSFSType{
	public int d =0;
	public B(){}
	public int getD() {
		return bountyCount;
	}
	
	public void setD(int d) {
		this.d = d;
	}
	
}
Created same class structure in C# for deserialization response from SFS server.

Code: Select all

public class A : SerializableSFSType
    {
         public int a =0;
         public A(){}
	
	public int getA() {
		return bountyCount;
	}
	
	public void setA(int a) {
		this.a = a;
	}
    }
public class B : A , SerializableSFSType
{
	public int d =0;
	public B(){}
	public int getD() {
		return bountyCount;
	}
	
	public void setD(int d) {
		this.d = d;
	}
	
}
Send class object of B from server and in client side type cast it into base class like:-
this.aObj = (A)sfsdata.GetClass("A");

Now values of class A variable is empty. It not set with server value.
aObj.a --> Do not have value
aObj.d --> have server sent value
Post Reply