C# Generic Casting with Linq?

Essentially you are doing System.Data.Linq. Binary b1; string str = be as string and System.Data.Linq. Binary b2 byte bArray = b2 as byte both str and bArray will be null you will need something like public class DataType where T : class { public T Value { get { // call ConvertFromBytes with linqBinary.ToArray() // not sure about the following; you might have to tweak it.

Return ConvertFromBytes((from d in Database where d. Value = Some Argument Passed select d. Value).First().ToArray()); } } protected virtual T ConvertFromBytes(byte getBytes) { throw new NotImplementedException(); } } public class StringClass : DataType { protected override string ConvertFromBytes(byte getBytes) { return Encoding.

UTF8. GetString(getBytes); } } public class ByteClass : DataType { protected override byte ConvertFromBytes(byte getBytes) { return getBytes; } }.

Essentially you are doing System.Data.Linq. Binary b1; string str = be as string; and System.Data.Linq. Binary b2 byte bArray = b2 as byte; both str and bArray will be null; you will need something like public class DataType where T : class { public T Value { get { // call ConvertFromBytes with linqBinary.ToArray() // not sure about the following; you might have to tweak it.

Return ConvertFromBytes((from d in Database where d. Value = Some Argument Passed select d. Value).First().ToArray()); } } protected virtual T ConvertFromBytes(byte getBytes) { throw new NotImplementedException(); } } public class StringClass : DataType { protected override string ConvertFromBytes(byte getBytes) { return Encoding.

UTF8. GetString(getBytes); } } public class ByteClass : DataType { protected override byte ConvertFromBytes(byte getBytes) { return getBytes; } }.

If you prefer, you can avoid generic syntax by using the var keyword. The var keyword instructs the compiler to infer the type of a query variable by looking at the data source specified in the from clause. The var keyword is useful when the type of the variable is obvious or when it is not that important to explicitly specify nested generic types such as those that are produced by group queries.

In general, we recommend that if you use var, realize that it can make your code more difficult for others to read. For more information, see Implicitly Typed Local Variables (C# Programming Guide).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions