|
I am trying to convert some code to .net framework 2.0 from .net framework 3.0.
the code of .net framework 3.5 is:
if (mItems.Exists(b => string.Compare(b.FileName, item.FileName, StringComparison.OrdinalIgnoreCase) == 0))
return;
It can run in .net framework 3.5 and can not run in .net framework 2.0.
Could someone tell me where the defferent things between 3.5 from 2.0 in the code are.
|
|
|
|
|
Lambda expressions were introduced in .Net 3.0. This should be enough:
if (mItems.Exists(string.Compare(b.FileName, item.FileName, StringComparison.OrdinalIgnoreCase) == 0))
return;
|
|
|
|
|
Thanks!
There is another problem. The parameter "b" whose type as same as parameter "item" is not defined.
And the parameter "b" have not defined anywhere. I try to change the name of parameter "b" to "a",it also could run. I am puzzled about this.
|
|
|
|
|
"The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. "
So b (and a) are your input parameters.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Thanks!
I have googled the lambda operator specifies and research it.There are some differences in syntax.
In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions.
Thank you.
|
|
|
|
|
That expression means that A variable "b" would be sent and the expression on the right side of "=>" would be executed on it. Now, you can see through your code and modify it accordingly. You can have a separate method that takes a variable of same type as "b" and returns the result or can declare the variable in the current method/class and use it.
If you are using VS2008, you can set the target framework as 2.0 and the original code should work.
|
|
|
|
|
Thanks!
I just back from a business trip. I have googled the lambda operator specifies and research it.There are some differences in syntax.
In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions.
Thank you.
|
|
|
|
|
But you can use C# 3 with .NET 2.0
|
|
|
|
|
Yes, I can.
I just want to konw why I could not debug the code successed in .net 2.0.
|
|
|
|
|
In that line of code, there shouldn't be any differences.
Lambda expressions compile to the same IL as anonymous methods in C# 2.0; it shouldn't be the problem.
The "Exists" method already was present for List<T> in .NET 2.0, so I don't see why your code would not run on .NET 2.0.
Generally, if you use the C# 3.0 compiler without setting any references on .NET 3.x assemblies (e.g. System.Core), the resulting binary will run on .NET 2.0.
What does "it can not run" mean? Do you get an exception? What is the error message?
|
|
|
|
|
Thanks!
I just back from a business trip. I have googled the lambda operator specifies and research it.There are some differences in syntax.
In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions.
"it can not run", I said, means that, I could not debug the code in .net 2.0. And I just want to konw why it was happened.
Thank you.
|
|
|
|
|
Why can't we just right click, insert > picture??
Why doesn't it work?? I simply get nothing when I do that!!
If you're familiar with this problem, can you shed some light on how to set it at runtime from a path in the hard disk rather than from a database field.. Probably as a parameter or whatever way it works.
Thanks!
|
|
|
|
|
Hi ,
Is there any good tools to create a good framework(Busines Logic and Datalayer) from a database ?
With Warm Regards...
|
|
|
|
|
|
MyGeneration[^] can be used to generate sourcecode that's based on a database-structure I are Troll
|
|
|
|
|
I have a datagrid that is being populated correctly. yet only the first row shows in the grid. I have a second row that shows nothing. However, if i click on the second row then I see the data. Is there some kinda setting I'm missing in properties or is it something else?
|
|
|
|
|
Hi,
can I know your data source contains only two rows?
Also, check and set the different color for 'BackColor' and 'ForeColor' properties of DefaultCellStyle in DataGrid.
Thanks,Gopal.S
|
|
|
|
|
Hi, I'm having problems in casting object to List<Game>, Game is another class. I'm using Reflection to invoke the method, however my method return a List, but the invokeMethod in Reflection returns me an object.
object returnType;
List<Game> gameList = (List<Game>)returnType;
When i tried to do this casting, it gives InvalidCastException. I've used, getType to check they are of the same type of list, however it cannot works. When i tried to compare them, i.e returnType.GetType().Equals(gameList.getType()), they are different.
Thanks for any help/suggestion. I've tried to search but failed to find any help.
|
|
|
|
|
What happens when you do GetType().ToString()? It could be that the object is null... not sure if that would cause trouble, but maybe. Also, if the types are defined in different assemblies, that may cause problems too (e.g., if the type you are casting to is defined in a different assembly than the type stored in the object). Perhaps you can create a simplified example of code we can run that demonstrates the problem?
|
|
|
|
|
Different assemblies! oh i compiled my code to a .DLL library. I'll load that assembly and run during runtime. However, inside the project I have forgotten to add that .DLL. Is that what is causing the problem? how do i add in the assembly to my project?
|
|
|
|
|
[A]System.Collections.Generic.List`1[AutomatedTestDriver.Game] cannot be cast to [B]System.Collections.Generic.List`1[AutomatedTestDriver.Game]. Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'. Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.
This is the exception it throws me
|
|
|
|
|
Create a simple example and perhaps I can assist you further. I've never tried it, but I'm pretty sure you are supposed to load the DLL using Reflection, and then you are supposed to get the type from that loaded assembly. But I'd need to see some simplified example of what you are doing to know for sure what's going on.
|
|
|
|
|
Hi guys,
I have question about a code-behind in C# for an ASPX file.
the thing is that I made a class and I want this class to inherit from System.Web.UI.Page.
but it seems that this refrence does not exist.the only thing that exists is System.Web!!!!
so if anybody could help me I'll appreciate it.
thanks
|
|
|
|
|
|
Hello guys,
I would like to introduce an option where my application would allow a user to use the program either with the default settings or it would allow certain customizations.
The application would allow to tweak certain parameters via controls (check boxes, radio buttons etc). What would be the best way to save them, so in future, if the application would be re-executed, that saved settings file would be initialized and appropriate actions would follow? Should I use serialization? Are there some better ideas?
Thanks.
modified 1-Aug-19 21:02pm.
|
|
|
|