dcsimg
Results 1 to 17 of 17

Thread: [RESOLVED] public Prpperty with arguments (parameters) in C#

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Resolved [RESOLVED] public Prpperty with arguments (parameters) in C#

    In VB.NET, public Prpperty with arguments (parameters) is allowed. But C# doesn't. How to achieve the uniform?

    Code:
        Public Property Border(ByVal Edge As EdgesEnum) As LineStylesEnum
            Get
                Return grd.getCellBorder(m_lRow, m_lCol, Edge)
            End Get
            Set(ByVal value As LineStylesEnum)
                grd.setCellBorder(m_lRow, m_lCol, Edge, value)
            End Set
        End Property

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: public Prpperty with arguments (parameters) in C#

    In C#, the equivalent is an indexer. There are some slight differences but the two perform the same functional purpose.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    In C#, the equivalent is an indexer. There are some slight differences but the two perform the same functional purpose.
    All StackOverFlow said Index... how about my case? Set a Cell's 4 edges with borders.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: public Prpperty with arguments (parameters) in C#

    I told you that you need an indexer and I provided a link to the relevant documentation. Follow the link, read the documentation, make an attempt to implement the information provided. Why do I have to spell that out? If you still have an issue then by all means post back and provide the specific details of that issue but if someone points you in a direction then you need to go in that direction, not stand there asking them what you would find if you went there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    I told you that you need an indexer and I provided a link to the relevant documentation. Follow the link, read the documentation, make an attempt to implement the information provided. Why do I have to spell that out? If you still have an issue then by all means post back and provide the specific details of that issue but if someone points you in a direction then you need to go in that direction, not stand there asking them what you would find if you went there.
    Thanks.
    I go to look at the Indexer solution.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    I just closed it. No idea how to do for my case.

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Your case is no different to any other case. If you can't follow the information provided in the page I linked to or many other places on the web then I just don't think you're trying very hard. It's just like any other property but it's named 'this' and it has a parameter list in brackets. Where's the difficulty?
    Last edited by jmcilhinney; Sep 17th, 2018 at 10:58 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    Your case is no different to any other case. If you can't follow the information provided in the page I linked to or many other places on the web then I just don't think you're trying very hard. It's just like any other property but it's named 'this' and it has a parameter list in brackets. Where's the difficulty?
    For you, it is easy, but for me, it is difficult. But for this case, I don't think you can solve it since StackOverFlow also do have solution.

  9. #9
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by DaveDavis View Post
    For you, it is easy, but for me, it is difficult.
    Sure, things are more difficult when you're less experienced but this is not so mind-bogglingly difficult that you can't even make an attempt. Like I said, it's just a regular property with a couple of small changes. I don't see you even having attempted to write a property so you appear to be making no effort at all. Even if you don't know how to write a property in C#, that doesn't make it hard. It just means that you have make an effort to find the information. That's the usual sticking point: the effort of finding information, not the difficulty of using it.
    Quote Originally Posted by DaveDavis View Post
    But for this case, I don't think you can solve it since StackOverFlow also do have solution.
    From the VB code you posted, I see no reason that it couldn't be done very easily. Maybe I'm missing something but I don't think so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    Sure, things are more difficult when you're less experienced but this is not so mind-bogglingly difficult that you can't even make an attempt. Like I said, it's just a regular property with a couple of small changes. I don't see you even having attempted to write a property so you appear to be making no effort at all. Even if you don't know how to write a property in C#, that doesn't make it hard. It just means that you have make an effort to find the information. That's the usual sticking point: the effort of finding information, not the difficulty of using it.

    From the VB code you posted, I see no reason that it couldn't be done very easily. Maybe I'm missing something but I don't think so.
    How you make conclusion for " this is not so mind-bogglingly difficult that you can't even make an attempt". I did try hard, but I can't get what I want.
    You teach me how to do fishing, but I need fish as well some time.

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by DaveDavis View Post
    I did try hard, but I can't get what I want.
    You say that, but I'm not seeing any evidence of it. That's the thing. I'm more than willing to help those who help themselves but if you can't show your best attempt here and indicate exactly where and how it doesn't work then, from my perspective, you haven't tried. Do you know how to write a property in C#? If not, why not? If you do, write one as a starting point. I said:
    It's just like any other property but it's named 'this' and it has a parameter list in brackets.
    So, if you have a property to start with, I'm quite sure that you can change its name to 'this' and then add a parameter list in brackets. If you get that far and it still doesn't work, THEN I'd accept that you have tried.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    You say that, but I'm not seeing any evidence of it. That's the thing. I'm more than willing to help those who help themselves but if you can't show your best attempt here and indicate exactly where and how it doesn't work then, from my perspective, you haven't tried. Do you know how to write a property in C#? If not, why not? If you do, write one as a starting point. I said:

    So, if you have a property to start with, I'm quite sure that you can change its name to 'this' and then add a parameter list in brackets. If you get that far and it still doesn't work, THEN I'd accept that you have tried.
    I really don't know how to do to achieve the uniform of VB.NET coding. Please help.
    Attached Files Attached Files

  13. #13
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    861

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by DaveDavis View Post
    I really don't know how to do to achieve the uniform of VB.NET coding. Please help.
    So what problem are you having with the attached code? Is it not working as expected? Is there an error? It is far easier for everyone if you provide as much information as you can regarding a problem, don't make people guess and require them to keep asking for more information it bits and pieces.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by PlausiblyDamp View Post
    So what problem are you having with the attached code? Is it not working as expected? Is there an error? It is far easier for everyone if you provide as much information as you can regarding a problem, don't make people guess and require them to keep asking for more information it bits and pieces.
    please read my question before you open mouth.
    in C#
    In VB.NET, public Prpperty with arguments (parameters) is allowed. But C# doesn't. How to achieve the uniform?

  15. #15
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Can you write a "regular" property in C#? If not, why not? Someone who was trying hard would at least have shown an attempt at that by now. By the way, I'm not downloading a ZIP file when all you need to do is post a tiny code snippet directly. There's a link to a C# beginners tutorial in my signature below and it covers writing your own properties. Why haven't you consulted something like that? You say that you're trying hard but it seems to me that you are trying to go from A to Z in one step and that isn't going to happen, no matter how hard you try, if you don't understand B, C, ..., X and Y. Stop trying to skip those intermediate steps because that is what makes things hard. If you break a problem down into smaller parts and tackle each part separately then each part is much easier than the whole.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    111

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by jmcilhinney View Post
    Can you write a "regular" property in C#? If not, why not? Someone who was trying hard would at least have shown an attempt at that by now. By the way, I'm not downloading a ZIP file when all you need to do is post a tiny code snippet directly. There's a link to a C# beginners tutorial in my signature below and it covers writing your own properties. Why haven't you consulted something like that? You say that you're trying hard but it seems to me that you are trying to go from A to Z in one step and that isn't going to happen, no matter how hard you try, if you don't understand B, C, ..., X and Y. Stop trying to skip those intermediate steps because that is what makes things hard. If you break a problem down into smaller parts and tackle each part separately then each part is much easier than the whole.
    I really don't understand what you means A,B,C...,X and Y.
    My question is very clear: how to write C#'s Public Property with arguments... If you don't know,just go away, don't try to simply judge People and don't point my nose to pretend you are expert.

  17. #17
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,038

    Re: [RESOLVED] public Prpperty with arguments (parameters) in C#

    Quote Originally Posted by DaveDavis View Post
    I really don't understand what you means A,B,C...,X and Y.
    Um, B, C, ..., X, Y are the steps between A and Z.
    Quote Originally Posted by DaveDavis View Post
    My question is very clear: how to write C#'s Public Property with arguments...
    And my answer was very clear: write a "regular" property, change the name to 'this' and add a parameter list in brackets. Do you know how to write a property in C# or not? If not, why not just say so? In that case, what efforts have you made to find out? I've pointed you to a tutorial that can teach you. Have you read that? If you do know how then why are you arguing instead of actually showing that? If you would show that then we could go on to the next step. I actually want to help but I'm not here to spoon-feed people. I expect to see their efforts that I can then work with.
    Quote Originally Posted by DaveDavis View Post
    If you don't know,just go away
    I do know, so can I stay?
    Quote Originally Posted by DaveDavis View Post
    don't try to simply judge People and don't point my nose to pretend you are expert.
    I'm judging based on what I see, just as all people do, but I'm not "simply" judging. If I was then I would have left ages ago. I'm still hopeful that you will actually take the obvious step, i.e. write a property, and then we can go from there. I don't pretend to be an expert but I do have some expertise, as you'd expect from someone who has been writing .NET code for a decade and a half. In that time, I've not only learned how to do things but also how to approach doing things. You seem set on just having me write your code for you, which isn't going to happen. I'm willing to help but I require you to do something to be helped with. Why won't you just write a property? Are you refusing on principle or are you unable and too embarrassed to say? I've provided plenty of guidance: terminology, links, steps. Will you be guided or do you just refuse?

    Anyway, write a property and I'll help you further. Refuse and you're on your own, as far as I'm concerned, anyway. If you're unable, say so, and then follow the tutorial link I pointed you to and learn.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width