C # — CS1503 — Аргумент 1: невозможно преобразовать из «строки» в «int»
Прежде чем ответить, я снова и снова проверял свой код, а также около часа искал похожий ответ. Компилятор продолжает выдавать ошибку CS1503, я не совсем уверен, как это исправить. Это строки 36 и 37, и я прокомментировал строки с ошибками 36 и 37. Он предназначен для базы данных, которая должна искать номерной знак и выводить другие данные в таблицу.
3 ответа
Как объяснено в комментариях, GetString также GetInt32 требует параметр типа integer. Это целое число — позиция поля в списке выбора полей. Если вы не хотите использовать позицию, вы можете написать
И эту простую строку можно легко преобразовать в метод расширения, добавив метод в статический класс, чей код
И это, наконец, позволяет писать
Конечно, то же самое можно написать и для GetInt32, который принимает имя поля. Кстати, если я не ошибаюсь, версия MySql имеет эти перегрузки прямо в сборке
GetInt32 ожидает параметр ‘int’.
Вы передаете в строке.
Используйте это вместо:
Возможно, вы захотите использовать микро ORM, например Dapper, чтобы упростить процесс.
Как исправить ошибку компилятора CS1503?

Собственно у DXMenuItem есть конструктор с параметрами string, void.Так вот ему не нравится как я вызываю функцию Count с параметрами.Не может конвертировать тип.Как мне правильно вызвать функцию с параметрами?Подозреваю что надо использовать лямбда-функцию,но не уверен.
![]()
У конструктора DxMenuItem , всего две перегрузки с двумя параметрами:
Вероятнее всего имелась ввиду вторая перегрузка принимающая обработчик click.
В этом случае действительно можно передать lambda
![]()
Дело в ожидаемых типах параметров конструктора DXMenuItem . Вряд ли тип второго параметра void (.
Собственно у делегата DXMenuItem есть конструктор с параметрами string, void.
Маловероятно также, что тип DXMenuItem является делегатом. Похоже, в процитированной фразе Вы пытаетесь описать сигнатуру метода: параметр — string , возвращаемое значение — void .
Cs1503 c как исправить
![]()
This forum is closed. Thank you for your contributions.
Answered by:
Question
Answers
The reason for this issue is what you’re trying to use desktop DLL on NETCF and this is not going to work.
That is, you can’t use this code at all. You also cannot add reference to Presentaioncore.dll, it’s a desktop DLL.
You need to remove this code and replace it with something which is device compatible.
Say, there’s an article about hosting MP control on NETCF on MSDN. Keep in mind it is rather complex and requires advanced skills.
This posting is provided "AS IS" with no warranties, and confers no rights.
- Marked as answer by Guang-Ming Bian — MSFT Tuesday, May 12, 2009 7:43 AM
All replies
The reason for this issue is what you’re trying to use desktop DLL on NETCF and this is not going to work.
That is, you can’t use this code at all. You also cannot add reference to Presentaioncore.dll, it’s a desktop DLL.
You need to remove this code and replace it with something which is device compatible.
Say, there’s an article about hosting MP control on NETCF on MSDN. Keep in mind it is rather complex and requires advanced skills.
This posting is provided "AS IS" with no warranties, and confers no rights.
error CS1503: Argument 2: cannot convert from ‘method group’ to ‘EventCallback’ #12226
I have checked other github blogs which related to this, mostly reported that, this has been fixed in preview 7 version. Right now, i have tested with preview 7 build but could not get resolve it.
Whether any syntax changes required to resolve in preview 7 version?

Screenshot:
Please find my component structure:
Rendering Page [Index razor page]
MyGenComponent.razor
Events.razor
GenericEvents.razor
NonGenericEvents.razor
To Reproduce
Clone this Github repository and run the application
We are also expecting the solution for this thread too
Additional context
The text was updated successfully, but these errors were encountered:
I agree that this still seems like an issue as creating verbose markup when handling events (without databinding).
Take the InputSelect for example. ValueChanged either requires T to be defined or a lambda expression within ValueChanged . Compounding the problem is ValueExpression which is also required, this is leading to some very clumsy looking markup @(()=> . This isn’t going to be the DX people expect when coming from jQuery, WebForms or even React.
From what I can tell, the problem is that the compiler does not use the the generic type parameter for type inference in method calls. Here’s a fairly trivial example:
We effectively get the same code when we code-gen a Razor file like this:
The compiler fails the type inferrence, picks the wrong overload for EventCallback.Factory.Create and generates the method group conversion error reported here.
From playing around, one of the ways to solve this would be to modify the code in TypeInference to pass the Action<T> in and produce the EventCallback<T> in there. This works well, but we now have the pain of having to code-gen an overload per overload of EventCallback.Factory.Create<T> . Changing the code-gen is going to be fairly involved, so I’m sending it back to triage to consider for a later release.
Workarounds that have been pointed out by others in the thread that work:
- Specify the type parameter
(I filed an issue to do a pass over blazor input elements to consider renaming T to TValue or something slightly better)