2011-06-13 2 views
0

변환에 문제가 있습니다. 이 변환에 Whate가 잘못 되었습니까? 여기 컴파일러 오류 메시지 : 암시 적으로 'long'유형을 'string'으로 변환 할 수 없습니다.

오류입니다 :

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0029: Cannot implicitly convert type 'long' to 'string'

if (hid_Action.Value.ToString().ToUpper() == "RENEW") 
{ 
    string strHFUpdate = string.Empty; 
    string srt = Convert.ToInt64(Session["AppId"] + ",'" + Session["CAAID"].ToString() + "','" + Session["UserType"].ToString() + "'"); 
    strHFUpdate = "oea_sp_update_HF_MC_Renewal_Status " + srt; 
    rProxy.GlobalSaveData(Session["CountyName"].ToString().Trim(), strHFUpdate.ToString()); 
} 

당신의 도움을 주셔서 감사합니다!

+0

정보가 충분하지 않습니다 ... 어떤 스크립팅 언어입니까? 물론 분명히 C#하지만 당신은 그것을 적어서 그것을 태그해야합니다 – Omer

+0

내가 제대로 당신을 이해하지 못했지만 그것은 asp.net, C#으로 작성되었습니다. – userstackoverflow

+0

이것은 도움이 될 수 있습니다. -http : //social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/35a1ffd9-b82a-435d-9efb-2e8a779d24c0/ –

답변

3
string srt = Convert.ToInt64(...); 

예, 작동하지 않습니다. 여기에 의도 된 것이 무엇인지 짐작하기가 어렵습니다. 아마도 괄호가 빠져있을 수도 있습니다.

0

는 여기에 문제

string srt = Convert.ToInt64 

당신은 stringlong 값을 할당하려고합니다. 당신은 할 수 없습니다. 그것을 .ToString()을 사용하여 문자열로 변경하면 할당 할 수 있습니다.

또 하나의 오류 Convert.ToInt64은 부동 소수점 숫자로 변환하지 않습니다. 즉, 1.1은 예외를 발생시킵니다. 변환하려는 문자열이 완전히 유효하지 않습니다. 어떻게해야할까요?

당신은 숫자에 추가, 모두 ToInt64을 (쉼표와 작은 따옴표로 문자열을 변환 할 수 없습니다
+0

내 전임자가 쓴 내용입니다. – userstackoverflow

+0

if (hid_Action.Value.ToString(). ToUpper() == "RENEW") { string strHFUpdate = string.Empty; strHFUpdate = "oea_sp_update_HF_MC_Renewal_Status"+ Convert.ToInt64 (세션 [ "AppId"]. ToString() + ","+ 세션 [ "CAAID"] ToString() + " ','"+ Session [ "UserType"] .ToString() + " '"); rProxy.GlobalSaveData (Session [ "CountyName"]. ToString(). Trim(), strHFUpdate.ToString()); } – userstackoverflow

+0

그리고이 오류가 발생합니다 : 입력 문자열이 올바른 형식이 아닙니다. 설명 : 현재 웹 요청을 실행하는 동안 처리되지 않은 예외가 발생했습니다. 오류 및 코드에서 시작된 위치에 대한 자세한 정보는 스택 추적을 검토하십시오. 예외 정보 : System.FormatException : 입력 문자열의 형식이 잘못되었습니다. – userstackoverflow

0

) 오버로드는 두 번째 매개 변수를 취

귀하의 위의 코드는 암시 적으로 다른 데이터로 문자열을 전송하려고하는데 ToInt64()는 단일 매개 변수로 오버로드를 수행 할 수 있습니다. ToInt64()는 문자열에서 변환을 지원합니까하지만 모두 그 오버로드는 두 개의 매개 변수 (아래 참조)

걸릴 [MSDN에서 : http://msdn.microsoft.com/en-us/library/system.convert.toint64.aspx]

ToInt64(String, IFormatProvider) Converts the specified string representation of a number to an equivalent 64-bit signed integer, using the specified culture-specific formatting information.

ToInt64(String, Int32) Converts the string representation of a number in a specified base to an equivalent 64-bit signed integer.

하지만 언급 한 바와 같이, 사용 한 경우에도 올바른 오버로드 기능을 , 숫자가 아닌 문자로 인해 문자열을 구문 분석 할 수 없습니다.

관련 문제