I couldn't find any report for this problem, so I created one. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=294156[^] Thanks for the advice. -sharoz
SHaroz
Posts
-
C# 3.0 Limitation: Type Inference & Lambda Expressions -
C# 3.0 Limitation: Type Inference & Lambda ExpressionsI saw an interesting point raised here: http://www.atrevido.net/blog/2007/08/02/C+Frustration.aspx[^] The C# 3 spec does not permit assigning a labmda expression to type infered value. So the following statement is invalid:
var Add = (int a, int b) => a + b;
The keyword
var
will give error CS0815, "Cannot assign 'lambda expression' to an implicitly typed local". If the type is changed fromvar
toFunc<int, int, int>
, the error goes away. The type of this lambda expression is not ambiguous, so the error must simply be a limitation in the type inference. Does anyone know if Microsoft has plans to fix this issue? If the type is known and expressible as a variable, then I see no good reason why this variable should behave differently than any other type-infered generic variable. I ran into this problem while using VS2008 beta 1, so if it works in beta 2, please let me know. -sharoz -
Windows "Vienna"/"Seven"/"7" FAQThey should be required to fix Vista before releasing a new OS. I spent all day all trying to install Vista 64-bit on a brand new PC with no luck (BSOD). To make matters worse, many computer manufacturers (such as Dell) won't even support it! :mad: -Steve
-
Method MatchingHello everyone, I am trying to find all methods that have a particular signature. In other words, I want all methods that match the return type and parameter types of a specified method. I have a solution, but I was wondering if a more elegant approach exists. Using delegates is one possibility, but delegates are not very “edit-and-continue” friendly. Here is my current solution:
void findSimilarMethods()
{
MethodInfo example = this.GetType().GetMethod("ExampleMethod");
ParameterInfo[] parameters = example.GetParameters();
List matches = new List();MethodInfo\[\] methods = this.GetType().GetMethods(); foreach (MethodInfo current in methods) { ParameterInfo\[\] currentParams = current.GetParameters(); if ( current.ReturnType != example.ReturnType ) continue; if ( currentParams.Length != parameters.Length ) continue; if ( !ParameterEquality(parameters, currentParams) ) continue; matches.Add(current); }
}
// a helper method to check parameter type equality
bool ParameterEquality(ParameterInfo[] a, ParameterInfo[] b)
{
if (a.Length != b.Length)
return false;
for (int i = 0; i < a.Length; i++)
if (a[i].GetType() != b[i].GetType())
return false;
return true;
}Any suggestions would be greatly appreciated. -Steve
-
Use VS2005 designer to create Panel?Add a new control to your project. Right click your project; select Add->New Item; then select User Control. Hope this helps. -SHaroz
-
'dumping Microsoft'I'm talking about setting up Linux and all of its packages in the first place. With MS and Apple, you just pop in the CD, turn on the computer, and after timezone and username selection, you're ready to go. Getting a PC with a good Linux distro and all of the apps preinstalled is not always easy. In turn, the IT staff would have to setup the partitions, drivers, and all of the other goodies. I'm not saying that Windows or OSX is completely carefree. I'm just saying that in terms of usability for the beginner, commercial software tends to win. The main exception to that is Firefox :)
-
'dumping Microsoft'Everyone is forgetting that Open Source Software typically requires more setup and maintenance. I'm NOT saying that MS software is maintenance free, but their setups and installations are far simpler than anything on a Linux environment. The tradeoff could still be beneficial. However, hardware and software costs need to take into account the service and maintenance costs associated with a higher requirement for more skilled IT staff. I would offer Apple as a suggestion, but those things are $$$ PRICEY $$$
-
I also got a C puzzleA blank line is legitimate in C. Comments also don't need semicolons, and neither do precompiler statements (i.e. #define, #include). The first line of an if or while statement doesn't need a semicolon. As a matter of fact, any statement could simply be written with the semicolon on the next line. :| Am I missing something?
-
.NET control in AccessDoes anyone know of a way to add a .NET control to an Access or VB6 form? I need to do this without editing the source code of the .NET control. Any help would be greatly appreciated. :) Thanks, Steve
-
dynamic memory allocationThanks Diminik :) Good job catching the error in my comments. I was just trying to make up a quick example of my question.
-
dynamic memory allocationIf I have a class called MyClass and three variables (var1, var2, var3), how do a create a multidimensional array of MyClass with dimensions the size of the variables. Here is an example:
class MyClass { int blablabla; //some stuff }; int main() { int i = 2; int var1 = ++i; // 2 int var2 = ++i; // 3 int var3 = ++i; // 4 MyClass ***table; table = new table[var1][var2][var3]; //I get an error here //VS says only the first dimension can be non-constant ... }
I've gotten so used to C# that I forgot how to do easy things like this.:eek: I would greatly appreciate any help. Thanks, Steve -
newline in win xpI tried mystream = freopen("myfile.out", wb, stdout) and it worked. The newline prints as one character. My problem is that I don't know how to find the file that stdout points to. I could avoid that if I knew a way to simply change the mode of stdout. I also thought that if the program is run like this "myprog > output.txt", argv[2] would be "output.txt". But that didn't work. Keep in mind that this needs to be ANSI compatable, so I can't use any function that starts with an underscore (i.e. _setmode). I tried looking up "CONOUT", but found nothing. Do you think you could offer any more advice? Thanks, Steve
-
newline in win xpI'm writing a program in c whose output is directed to a file (i.e. myprog > myfile). My problem is that whenever I print a newline character, printf("\n"), the program outputs both a carriage return and a newline. So while the output should have just one character whose value is 10, the program outputs a 13 followed by a 10. I this this might have something to do with Windows XP. Has anyone else heard of this? I would greatly appreciate ANY help that can be offered. Thanks, Steve
-
Screen ResolutionI don't know about changing the resolution, but to check it use Screen.
-
screen resolutionThanks. I knew it would be something obvious like "Screen". I kept trying to find a "Display" object. :laugh: -Steve
-
Change the title bar etc?The only way I know of to do this is to set the FormBorderStyle to None. Then, add controls and modify their behavior and appearance however you want. This probably isn't the answer you were looking for, but I hope it helps. -Steve
-
screen resolutionI hope this is an easy question: How do i find the screen resolution in .NET? I want to make sure that if the resolution was reduced, my program won't come up out of the visible range. Thanks, Steve
-
Remoting File TransferI can send a file from the server to the client by having the client call a function which returns a FileStream. It works perfectly. I tried to send a file from the client to the server by having the client call a function with a filestream as a parameter. Unfortunately, the client gives me an error saying the the remoting proxy has no channel sink. :confused: The client's call:
T.SendFileTest2(New FileStream("C:\in2.txt", FileMode.Open))
The function in the hosted object:
Public Function SendFileTest2(ByVal FSL1 As FileStream) As Boolean Dim Buffer(4096) As Byte Dim readed As Integer Do readed = FSL1.Read(Buffer, 0, 4096) Dim i As Integer Dim str As String For i = 0 To readed - 1 str += Convert.ToChar(Buffer(i)) Next MsgBox(str) Loop Until readed < 4096 FSL1.Close() FSL1 = Nothing End Function
I would greatly appreciate any help on this. Thanks, Steve
-
Remoting issueSorry, I don't know. I'd really need a closer look at your code to understand what you're doing. Hopefully, someone else can give it a shot.
-
Resizing FormSet the FormBorderStyle of the form. There are 6 or 7 different styles, so pick which one best suites you.