Home > Net >  In the.net Framework 4.5 version 3.5 class library file method call
In the.net Framework 4.5 version 3.5 class library file method call

Time:03-30

The following is the.net Framework 3.5 created in method in a class library file:
 
///& lt; Summary>
///converted to string type string
///& lt;/summary>
///& lt; Param name="s" & gt; Access to need to transform the value & lt;/param>
///& lt; Param name="format" & gt; Need to format the digits & lt;/param>
///& lt; Returns> Returns a new string & lt;/returns>
Public static string ToStr (this object s, string format="")
{
string result="";
Try
{
If (the format=="")
{
Result=s.T oString ();
}
The else
{
Result=the string. Format (" {0: "+ Format +"} ", s);
}
}
Catch
{
}
return result;
}



When the above class library files are imported into the.net Framework 4.5 web App_Code folder of the project, in the class library file to call its methods are as follows:
 
Public static string GetRequestStr (this object c, string key, bool filterSQL=true)
{
[key] string textValue=https://bbs.csdn.net/topics/HttpContext.Current.Request ToStr (" ");//there is a problem here
If (filterSQL & amp; & TextValue. The Trim ()!="")
{
TextValue=(https://bbs.csdn.net/topics/textValue.filterSQL);//a string of verification, determine whether contain special characters or keyword, if contain special characters processing,
}
Return textValue;
}


Page prompts questions as follows:
CS0121: The call is ambiguous between The following methods or properties: 'UserUtility. Utility. ToStr (object, string)' and 'UserUtility. Utility. ToStr (object, string)'
  • Related