G
Gomaw Beoyr
Two question about the "partial classes" (in the next wersion of
..NET).
Question 1
==========
Will partial classes (in the next version of C#) have to be
declared "partial" in ALL places.
I.e. do we have to need to write:
File 1:
public partial class AB {
public int A;
}
File 2:
public partial class AB {
public int B;
}
Or will it be possible to write:
File 1:
public class AB { // Omit "partial" here
public int A;
}
File 2:
public partial class AB {
public int B;
}
Note that in the latter case, it would be possible to extend
ANY class, e.g. the ValueType class:
Some file:
namespace System {
public partial class ValueType {
public double Inverse {
get {
return 1.0/(double)this;
}
}
}
}
which would add an "Inverse" property to the types float, double,
int and so on:
2.Inverse == 0.5
4.0.Inverse == 0.25
It would definitely be nice to have some kind of mechanism that
would make already implemented classes "partial", thus making it
possible to extend them this way.
Question 2
==========
Must the interfaces of partial classes be declared in all places?
I.e. do we have to write:
File 1:
public partial class X: IA, IB, IC, ID {
// Methods of interfaces IA and IB
}
File 2:
public partial class X: IA, IB, IC, ID {
// Methods of interfaces IC and ID
}
Or, will it be possible to write:
File 1:
public partial class X: IA, IB {
// Methods of interfaces IA and IB
}
File 2:
public partial class X: IC, ID {
// Methods of interfaces IC and ID
}
The second way would definitely make implementation easier.
/Gomaw
..NET).
Question 1
==========
Will partial classes (in the next version of C#) have to be
declared "partial" in ALL places.
I.e. do we have to need to write:
File 1:
public partial class AB {
public int A;
}
File 2:
public partial class AB {
public int B;
}
Or will it be possible to write:
File 1:
public class AB { // Omit "partial" here
public int A;
}
File 2:
public partial class AB {
public int B;
}
Note that in the latter case, it would be possible to extend
ANY class, e.g. the ValueType class:
Some file:
namespace System {
public partial class ValueType {
public double Inverse {
get {
return 1.0/(double)this;
}
}
}
}
which would add an "Inverse" property to the types float, double,
int and so on:
2.Inverse == 0.5
4.0.Inverse == 0.25
It would definitely be nice to have some kind of mechanism that
would make already implemented classes "partial", thus making it
possible to extend them this way.
Question 2
==========
Must the interfaces of partial classes be declared in all places?
I.e. do we have to write:
File 1:
public partial class X: IA, IB, IC, ID {
// Methods of interfaces IA and IB
}
File 2:
public partial class X: IA, IB, IC, ID {
// Methods of interfaces IC and ID
}
Or, will it be possible to write:
File 1:
public partial class X: IA, IB {
// Methods of interfaces IA and IB
}
File 2:
public partial class X: IC, ID {
// Methods of interfaces IC and ID
}
The second way would definitely make implementation easier.
/Gomaw