Hi everyone,
New I would like to ask the types of programming such declaration is this:
Please people just help
1. Function declaration
IEnumerable LoadMyEntities (Expression > predicate)
{
/ / Coding here ...
}
===================
2. this.Load + = new System.EventHandler (this.Page_Load);
===================
3. public enum e_IsReimbursement
{
NO = 0,YES = 1
}
===================
4.public enum e_DaysOfWeek
{
Monday,TUESDAY,WEDNESDAY,Thursday,FRIDAY,SATURDAY,SUNDAY,HALF_SATURDAY
}
===================
5. Declaration type enum is nothing better than a const variable
public const string DEFAULT_SELECTED_DEPARTMENT = "<---- Select Department ---->";
===================
6. Text ie what
private T GetObjectFromLmsCache (QueryParser queries, out string sqlString, and out bool keyExist)
{
/ / Coding here ...
}
===================
7. Explained in this function declaration
public override IList getObjectListFromDb (QueryParser query)
{
string sqlString;bool keyExist;IListreturnValue = GetObjectFromLmsCache > (queries, out sqlString, and out keyExist); if (keyExist){return returnValue;}
returnValue = base.getObjectListFromDb(query); SetObjectToLmsCache (sqlString, returnValue);return returnValue;
}
Happy if people interested tohelp.
Sincerely thank you.

VulpesPosted Sep 20, 2012, 7:05 AM
I see you've realized that you often need to cast to object first before you can cast to T in order for generic code to compile.
Here's a simple example of using an expression tree. In the Person.IsTeenager() method, the lambda expression which determines if that's the case is automatically converted to an expression tree of the appropriate type.
This expression tree is then used in the query to determine which Persons in an array of Persons are teenagers. It needs to be compiled first to convert it into a delegate so that it can be used in the Where clause of that query:
The output should be:
Trung Do ThanhPosted Sep 20, 2012, 11:29 PM
I understand your current reply, I'll try to make example to clearer about this.
Thank you so much.
Trung Do ThanhPosted Sep 19, 2012, 11:49 PM
I understand about object
I changed your code that is: How do you thinhk about my new code. :)
I want to know clearer about question 1 that is "
VulpesPosted Sep 19, 2012, 9:03 AM
Consider this simple program:
using System;
class Test
{
static void Main()
{
int i = GetDefault
Console.WriteLine(i);
DateTime dt = GetDefault
Console.WriteLine(dt);
Console.ReadKey();
}
static T GetDefault
{
return default(T);
}
}
Here GetDefault is a generic method with a type parameter T (enclosed in angle brackets). This method simply returns the default value of whatever type parameter is used. The type of this default value will, of course, be T itself.
So, you can call it with a type parameter of int, DateTime or anything else you like. It will always work.
GetObjectFromLmsCache is similar, though more complicated as it takes a number of 'ordinary' parameters as well. So whatever type parameter is passed, a value of that type will be returned by the method.
The type parameter can itself be a generic type such as IList
Any clearer?
Trung Do ThanhPosted Sep 19, 2012, 7:28 AM
+ private T GetObjectFromLmsCache (param...)
+ private T GetObjectFromLmsCache (param...)
What is
VulpesPosted Sep 19, 2012, 7:07 AM