Non-invocable member "System.Windows.Forms.Control.Text" cannot be used like a method.Here is the code:

if (OffenceBox.Text != "") { AddBook(int.Parse(AgeBox.Text), NameBox.Text, AddressBox.Text, (HeightBox.Text), OffenceBox.Text()); } else { MessageBox.Show("Age must be max 3 numbers in length"); } }How can I fix this problem?

EDIT:Fixed the error and now encountered another:Argument 4: Cannot convert String to int and I can"t seem to fix the problem.

You are watching: Non invocable member cannot be used like a method


c#
Share
Improve this question
Follow
edited Aug 8 "13 at 20:54
Angelrawzz
asked Aug 8 "13 at 20:43
*

AngelrawzzAngelrawzz
74922 gold badges66 silver badges1010 bronze badges
0
Add a comment |

4 Answers 4


Active Oldest Votes
93
Where you"ve written "OffenceBox.Text()", you need to replace this with "OffenceBox.Text". It"s a property, not a method - the clue"s in the error!


Share
Improve this answer
Follow
answered Aug 8 "13 at 20:44
*

pattermeisterpattermeister
2,9122222 silver badges2727 bronze badges
2
Add a comment |
9
It have happened because you are trying to use the property "OffenceBox.Text" like a method. Try to remove parenteses from OffenceBox.Text() and it"ll work fine.

Remember that you cannot create a method and a property with the same name in a class.

By the way, some alias could confuse you, since sometimes it"s method or property, e.g: "Count" alias:

Namespace: System.Linq

using System.Linqnamespace Teste{ public class TestLinq { public return Foo() { var listX = new List(); return listX.Count(x => x.Id == 1); } }}

Namespace: System.Collections.Generic

using System.Collections.Genericnamespace Teste{ public class TestList { public int Foo() { var listX = new List(); return listX.Count; } }}
Share
Improve this answer
Follow
edited Apr 12 "18 at 4:42
answered Jan 25 "16 at 18:33

*

Daniel MoreiraDaniel Moreira
42144 silver badges1616 bronze badges
Add a comment |
4
As the error clearly states, OffenceBox.Text() is not a function and therefore doesn"t make sense.


Share
Improve this answer
Follow
answered Aug 8 "13 at 20:44
*

SLaksSLaks
818k169169 gold badges18431843 silver badges19181918 bronze badges
Add a comment |
1
I had the same issue and realized that removing the parentheses worked.Sometimes having someone else read your code can be useful if you have been the only one working on it for some time.

E.g.

cmd.CommandType = CommandType.Text(); Replace: cmd.CommandType = CommandType.Text;


Share
Improve this answer
Follow
answered Jan 15 "19 at 18:14
*

wendykcodingwendykcoding
4711 silver badge1111 bronze badges
Add a comment |

Your Answer


Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

See more: Drop It Like Its Hot Acapella, Drop It Like It'S Hot By Snoop Dogg


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Submit

Post as a guest


Name
Email Required, but never shown


Post as a guest


Name
Email

Required, but never shown


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged c# or ask your own question.


The Overflow Blog
Featured on Meta
Linked
-1
I just start programing and the following error does not stop appearing error CS1955 Non-invocable member 'Component.tag' cannot be used like a method
-2
How to simplify Environment.NewLine()?
0
Error CS1955Non-invocable member 'MessageModel.Welcome' cannot be used like a method
0
Passing a List, with a predefined structure, as parameter to a different Form
Related
8
Non-invocable member 'System.Web.HttpRequest.ServerVariables' cannot be used like a method
812
Converting string to byte array in C#
0
Non-invocable member "HomeController.ServicesList" cannot be used like a method
0
Non-invocable member 'List.FilterFunction' cannot be used like a method
1
linq non-invocable member - cannot be used like a method
0
Non-invocable member 'OperationResult' cannot be used like a method
Hot Network Questions more hot questions

Question feed
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader.


lang-cs
Stack Overflow
Products
Company
Stack Exchange Network
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.11.10.40696


Stack Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.