नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'var': you cannot capture a variable that has a managed or WinRTtype
Remarks
You cannot capture a variable that has a managed type or a Windows Runtime type in a lambda.
To correct this error
- Pass the managed or Windows Runtime variable to the parameter list of the lambda expression.
Example
The following example generates C3498 because a variable that has a managed type appears in the capture list of a lambda expression:
// C3498a.cpp
// compile with: /clr
using namespace System;
int main()
{
String ^ s = "Hello";
[&s](String ^ r)
{ return String::Concat(s, r); } (", World!"); // C3498
}
The following example resolves C3498 by passing the managed variable s to the parameter list of the lambda expression:
// C3498b.cpp
// compile with: /clr
using namespace System;
int main()
{
String ^ s = "Hello";
[](String ^ s, String ^ r)
{ return String::Concat(s, r); } (s, ", World!");
}