fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC:

X# or C#? 13 Oct 2020 15:02 #16188

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • The last few weeks I've been working on a project which started years ago in C# and has been enhanced a lot, also in C#. More than once programmers decide to work on new project in C# instead of X# with the argument that there are many samples in C# ready to be used. I recognize that; many of the things I want to program start with a working C# sample from Stackoverflow, Codeproject and more. I always search until I have found code which seems complete & working, with the least amount of program lines and preferably the least amount of no doubt clever but often incomprehensible code.

    As we still have most our code in VO and the VO IDE is far better and more usable than VS in nearly every respect I am still not a heavy X# user. I haven't even installed the last few updates anymore. The previous X# versions work for what we have to maintain and there's nothing in the Whatsnew list of the last few versions which affect our code. I am not saying that what has been changed or added is not useful, on the contrary, but not for us. We will probably upgrade like we do with Windows 10: 2-3 times a year is fine unless something is changed where we are waiting for.

    But this having said: after these weeks of work in C# it becomes clear how much more VO and hence X# offers than C#. Nearly every VO/X# function for example does not have an equivalent in C#. E.g. At3, Crypt, Left. I always end up with some multi line code sometimes with hard to understand Linq code in it. That is also the case for most other classes as well; .Net has some out-of-the-box functionality but more than once it still requires at least as much code as needed in VO in excellent tools like Fabtools and more libraries many of us use.

    In short, even when you are not doing much (yet) in X# and therefor think that you might as well continue in C#: you will definitely end up spending much more time to get simple things working. A good thing to consider if you are thinking about the using special Fox offer (See www.xsharp.info/store/xsharp-2-6-special-autumn-promotion )

    @Robert/Chris: one small remark: I noticed in the help that some functions are difficult to find. E.g. try 'functions' and a lot of functions do not appear in the results. There are 14 topics all called Functions, Globals and Defines, but that is one for each different DLL. Also in the Contents.

    The VO help does have a more logical/accessible Function Reference (alphabetic and by Category, with the categories named like string, Date & TIme etc which is better than named after the DLL a function can be found in).

    In case you don't know anything else to do ;)

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 13 Oct 2020 15:21 #16189

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Dick,
    I'm preferring X# over C# because of a few strengths:
  • X# code is easier to read than C# code because the parentheses are replaced by explicit words (like endif/enddo/next)
  • I can use old VO code
  • we have a macrocompiler in the language
  • the product has native access to DBF files
  • and the most important: We have an excellent support team!
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    X# or C#? 13 Oct 2020 15:34 #16190

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Dick,

    That's not true, the .Net Framework (so both X# and c#) has functions (methods) for almost everything that VO ever had and way, way, way more than that in almost every aspect, it just uses different names for those (IndexOf() instead of At() etc). What X# has that c# doesn't, is the integrated macro compiler and native dbf access mainly. And of course the xBase specific compatibility aspects, including the VO-compatible SDK classes, xBase compatible functions etc.

    Personally for me the biggest advantage of X# over c# is the syntax, because the syntax of c# is an absolute NO NO for me, and I am very glad that I can do all my development work in a language with a syntax I like and I am now optimistic I will never ever have to do anything in c# for the rest of my life :). (To be clear, a language with syntax like that of Delphi would had also been fine). For other people there are other reasons to use X#, for example for developers with large VO apps, X# offers probably the only sensible path to bring them to today's and future standards. I am sure this will be the case for VFP developers soon as well.

    In short, it totally depends on you and your needs and preferences, what language you will choose. Availability of At() and Left() is not a factor though, what is a factor is the way that you use those functions in c# and X# (including the always zero-based aspect in c#). IMO also code snippets availability is not really a factor either, because, yes, samples are written in c#, but after getting used to it a bit, translating them to X# becomes very easy. Availability of programmers willing to code in X# compared to c#, yes I agree this can be an important factor.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    X# or C#? 13 Oct 2020 15:37 #16191

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Wolfgang,

    wriedmann wrote: Hi Dick,
    I'm preferring X# over C# because of a few strengths:


    100% agreed for all reasons.

    Try to ask something at answers.microsoft.com or MSDN. Lots of end users to help, sure, but official Microsoft support engineers hardly reply more than "We have not enough information to reply...".

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 13 Oct 2020 15:58 #16192

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Chris,

    Chris wrote: Hi Dick,

    That's not true, the .Net Framework (so both X# and c#) has functions (methods) for almost everything that VO ever had and way, way, way more than that in almost every aspect, it just uses different names for those (IndexOf() instead of At() etc).


    I should have formulated it a bit more precise. In case of the Left function: this is a totally logical function to remember (a bit less maybe for At3) but in C# there's no Left function. I understand it used to exist in VB. If you search for a way to accomplish the same result, you will find many examples not using IndexOf, below a few examples I found.

    Meaning that none of the people who replied came up with IndexOf but with multi line functions like below.

    Same for Crypt. I may have missed it but I have not found anything else than (up to) pages of code for what is 1 function in VO/X#:

    docs.microsoft.com/en-us/dotnet/standard...rity/encrypting-data
    social.msdn.microsoft.com/Forums/vstudio...?forum=csharpgeneral

    My C# program is full of workarounds for missing functions, I think it must be more lines than all FabTools together :P . There is no single function in the program (which includes many collected sample code snippets) that is easier or more logical than an equivalent in VO/X#. And then indeed I am still not talking about the mental ill person who invented the 0 based indexes in C#)

    Dick

    Several 'solutions' found if you simply search for a Left function in C#:

    - char[] array = yourStringVariable.Take(5).ToArray();

    - string firstFivChar = new string(yourStringVariable.Take(5).ToArray());

    - public static class StringExtensions
    {
    public static string Left(this string value, int maxLength)
    {
    if (string.IsNullOrEmpty(value)) return value;
    maxLength = Math.Abs(maxLength);

    return ( value.Length <= maxLength
    ? value
    : value.Substring(0, maxLength)
    );
    }
    }

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    X# or C#? 13 Oct 2020 16:58 #16193

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Dick,

    In (pure) .Net, instead of Left() (and SubStr()), you would simply use Substring(), it's meant to do the same thing:

    cVar:Substring(0,3) // take the first 3 chars

    What is different, is that it has different semantics than Left(). First of all, it is not named "Left" :). Also it is not "forgiving", you cannot pass it NULL strings, or string lengths which are longer than the actual string length, like you can do in VO. And worse of all (IMO), it is zero char based. But those are just semantics, for me and you Left() in VO and X# are a lot more intuitive to use than Substring(), but those are only our own preferences, other people may prefer the "cleanness" of the .Net implementation.

    What I find much worse, is that there's really not a Right() method in .Net, you can emulate with Substring() again, but the syntax becomes even uglier IMO. Still, that's ugly to me, but it doesn't mean that .Net does not have absolutely everything! Also it is very easy to implement a Left() and Right() extension method that works exactly like in VO, define it in a base library and use it like that everywhere in your code:

    FUNCTION Start() AS VOID
    LOCAL c := "abcdef" AS STRING
    ? c:Right(3) // def
    
    STATIC METHOD Right(SELF cString AS STRING, nCount AS INT) AS STRING
    // implement it here exactly the way VO works. Or any other way you prefer


    About Crypt() ,maybe there is no .Net function available that works exactly the way that the Crypt() function works. But this is probably because only VO developers use this exact crypt mechanism (which is very weak anyway). Search for .Net cryptography, you will find millions of hits..

    Dick, I absolutely agree there are a lot of reasons to prefer X# over c#. Semantics and syntax are two such reasons, if you do prefer the semantics and syntax of X#, like I also absolutely do. But, content, this is absolutely not a reason for choosing one over the other.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    X# or C#? 13 Oct 2020 17:25 #16194

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Chris,

    I was not looking for a Crypt function giving the same results as in VO/X#. After all, even from VO to X# you had to add a CryptRaw. But I have not found any 1 line Crypt/Decrypt C# function at all. I haven't checked millions of pages, I admit, but the first few dozen of search results doesn't contain any. Nada. If anyone know a ready to use .Net (De)crypt function (not another self coded workaround) I'd love to hear that.

    Same for Right() indeed. And really many, many more functions. And many other programmers who don't realize the existence of simple(r) solutions, when asked.

    That's why I don't understand that you write "it doesn't mean that .Net does not have absolutely everything!" . Because IMO, that is exactly what it means. .Net doesn't have a solution for many functions while VO/X# has. That I can write extension function doesn't count. My first computer was an Oric 1 and it didn't have an OnError functions which I very much wanted to use. I wrote it in 6502 machine language (and even earned 100 GBP as I sent it to a computer magazine which published it). It worked very well but I am not going to say that the Oric had absolutely everything in the (Basic) language :lol:

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 13 Oct 2020 18:16 #16195

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Dick,

    With a quick search about "Crypt in .Net", I found this in 2 seconds: www.codeproject.com/Articles/9183/A-C-im...tation-of-Unix-crypt

    Obviously there are a lot more than that. Probably there are already available crypt methods also in the system libraries, but even if not, it does not make any difference, when you can download anything from anyone that has ever developed something that you need in .Net and you can use it right away. And trust me, you can find EVERYTHING, any kind of crypt mechanism you have imagined or not. It's the nature of .Net, it is completely open, so you can use what millions and millions of other developers have already created in any language, from any language.

    About Right(), as I said of course this is available in .Net:

    cVar:Substring(c:Length - 3 , 3) // Right(cVar,3)

    It's just not named Right() or Left(), probably because to the eyes of the people who created the system libraries, it would had been redundant to define also those methods, while it is easy (in their eyes) to already achieve the same result with Substring(). Personally I completely dislike this (and many other similar) decisions, but this is just a matter of taste, doesn't change the fact that almost everything is available in .Net.

    I am really curious to hear which regular function of VO does not have a one-line equivalent in .Net. Usually they behave differently, but all is there I think. Except of course if you are referring to very specialized functions like MemoLine() or dbf functions and similar.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    X# or C#? 13 Oct 2020 19:03 #16196

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Chris,

    Chris wrote: Hi Dick,

    With a quick search about "Crypt in .Net", I found this in 2 seconds: www.codeproject.com/Articles/9183/A-C-im...tation-of-Unix-crypt

    I am really curious to hear which regular function of VO does not have a one-line equivalent in .Net.



    Well...Crypt hasn't. Your 2 seconds search gives the same result as my 2 seconds (and more than 2 seconds searches). This is a complete library to get a Crypt function. Not a one line function. And trying to push incomprehensible code in 1 line to get a function for "Right" doesn't count as a 1 line function either IMO. For VO/X# this is all included in the default libraries in a easy to understand functions. Which means that in nearly every respect I feel like getting backwards with .Net, VS etc.

    That is what I am trying to say all the time. There's about nothing in .Net ready to use. My C# program is filled with workarounds for missing functions. Crypt no doubt will have to be added.

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    X# or C#? 13 Oct 2020 19:25 #16197

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Dick,

    As I said I agree that Right() in VO feels much better to use than Substring() in .Net. On the other hand, there's absolutely nothing stopping you from using Right() also in c#, if you add a reference to the X# runtime. Or define it yourself to make it work exactly the way you want it to, I don't see any reason why not simply doing that.

    In .Net, you have method overloading, dozens of collection classes (compared to simple ARRAY), generics, nested classes and methods, reflection, 64 bit integers, decimal type, namespace grouping, interfaces, extension methods, dozens and dozens "new" language constructs, millions of already developed classes to use instantly, the list of things that we could only had dreamed off in VO is endless.

    But if you do prefer VO, and you are more comfortable and productive with it, then of course the best choice for you is to stay with VO, absolutely nothing wrong with that of course. Different people, different preferences, so everybody should use what their prefer. I also like some things the way they were done in VO better than they were done in .Net. How VS generally works is one example :). But the statement "There's about nothing in .Net ready to use" could not possibly be any further from the truth...
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    X# or C#? 15 Oct 2020 15:45 #16208

  • Terry's Avatar

  • Terry


  • Posts: 200
  • PMFJI

    An interesting exchange of views here.

    The fact is that any No Net language itself "contains" .Net features. Whether C# or any derivative, the language provides access to the full gamut of .Net features.

    To illustrate I have extracted a few diagrams from a document designed to show how we can architect any program whilst thinking in real-world terms.

    Just my two penn'orth in the debate.

    Terry
    Attachments:

    Please Log in or Create an account to join the conversation.

    X# or C#? 15 Oct 2020 20:15 #16214

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Chris, Terry,

    Chris wrote: But the statement "There's about nothing in .Net ready to use" could not possibly be any further from the truth...


    Ok, I admit I exaggerated a bit. But a fact is, unfortunately, if there's a imaginary balance between the benefits gained from .Net features (like the enumeration you gave) and the daily functions etc I need in my all my programs which are not readily (and easily) available in C# then the balance is heavily tipping over to the right - the extra time I nearly invariably need to search workarounds for something I need done has much more impact than the time I save (or real usable improvements I can implement etc.) through those .Net features.

    Just including one or more X# DLL's to have access to a ready-to-use X# function is a very interesting idea however. I am going to try this!

    Terry wrote: The fact is that any No Net language itself "contains" .Net features. Whether C# or any derivative, the language provides access to the full gamut of .Net features.


    You are right in that: as written in my reply to Chris I do realize that there's some (but very little) advantage to me in everything .Net has to offer but many disadvantages to using C# (including what Chris also experiences as disadvantages of C#), for daily practice. I did write this however to point out that although using C# may seem a logical choice to work with if you are searching for a successor for VO (and do not need to convert existing VO code or access DBF files) but X# is a lot more useful than C#. And that's probably more interesting than our (Chris & me) difference of opinion how much you can really benefit from what .Net offers. Something like .Net/VS/X# versus VO is a whole different discussion :cheer:

    By the way Terry: you put a lot of effort in your diagrams!

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    X# or C#? 15 Oct 2020 23:42 #16217

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Dick!

    ic2 wrote: Ok, I admit I exaggerated a bit. But a fact is, unfortunately, if there's a imaginary balance between the benefits gained from .Net features (like the enumeration you gave) and the daily functions etc I need in my all my programs which are not readily (and easily) available in C# then the balance is heavily tipping over to the right - the extra time I nearly invariably need to search workarounds for something I need done has much more impact than the time I save (or real usable improvements I can implement etc.) through those .Net features.


    Hehe, "a bit"! ;)

    Anyway, I seriously believe that if you find the disadvantages moving to .Net are more than the advantages, then there's nothing wrong with staying with what you like using more. No point using something if you dislike it and you do have the option to use it or not.

    But I still did not understand which are the functions that you daily use and are moving from .Net. Left() is already here with Substring(nChars), Right() is also available, although admittedly less intuitive because it needs 2 params. Which are the other ones that you are missing? I am geniounly curious about this!
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 12:58 #16221

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Chris,

    Well you asked for it, here we go B)

    These are a few samples but on working with C# I am almost always held up because something is not available or not working as I expect. Sure, part of it is because I have worked much longer with VO than with C#. But everything together I hardly have the feeling that a lot is present in C#/.Net. Also of course, my Photo program would probably have been difficult to create in VO, although maybe FabTools would help a lot already. And I do realize that for future projects, I must work in X#/.Net. So even if find working in VO more comfortable in nearly all respects, I will be working in .Net languages more and more the next few years.

    Here's a selection of what I missed in C# or had to search quite some time for before finding a solution:

    Left
    Right
    Occurs
    Crypt
    ApplicationExec(ExecWhileEvent)


    I know that in some cases there is even a 1 line solution but the sole fact that people ask it and multiple solutions are offered, often multi line and not really readable later is a huge disadvantage.

    Example: If anyone would ask for VO: I need the number of times a substring occurs in a string he would get one simple and understandable reply: Occurs.

    But in C# you get many solution, none of which are clear to understand at a glance, e.g. the only 1 line suggestion I found:

    Regex.Matches(input, "value").Count

    That means that I often have to spend time searching the internet (while in VO/X# I can find a solution in the help usually quickly, even if it's a function I hadn't used before, and then when I read my code later, Occurs is understandable and Regex.Matches(input, "value").Count is not.

    Other issues

    - Multiple methods which do not return a value to determine success but failing execution should be arranged in the Exception Handler. E.g.
    DeleteSubKey (Registry) returns Void while Bool should be the right return type

    - Zero based indexing requires adapting ever samples and working time, like person number 1 in an array is array element 0.
    Classes having the same name but different namespaces ("ambiguous reference")


    - Visual Studio replaces tabs by spaces a.o. when copying or moving code

    Apart from that it is the time I loose (compared to VO) because:

    - a : or { / } is misplaced and all program lines in the editor turn red (I usually remove my last edited method completely to a text-editor and step by step insert it again. Caused mainly because you can't edit 1 entity in .Net.
    - having to work with escape characters because C# assigns all kind of different and useless meanings to special characters (like filenames needing a @ or double \)
    - switch statement: every single switch requires a separate break statement (which makes you wonder why they created this statement, a series of if statements is less work
    - I have documented all the error messages which caused me more than 10 minutes search before I found the cause, often because the error text is cryptic at best. First you have to copy the error, then strip the unnecessary header and detailinfo VS adds to it, before being able to find the cause. Here's a small selection:

    CS0120: An object reference is required for the nonstatic field, method, or property 'foo'
    Event Click can only be bound to properties of delegate type RoutedEventHandler
    Inconsistent Accessibility: Parameter type is less accessible than method
    The modifier 'public' is not valid for this item
    Error CS1503 Argument 1: cannot convert from 'string' to 'char'
    Error CS8070 Control cannot fall out of switch from final case label
    Error CS0079 The event 'ToggleButton.Checked' can only appear on the left hand side of += or -=
    Error CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
    Error CS0123 No overload for '....' matches delegate 'RoutedEventHandler'
    Error CS1010 Newline in constant

    I especially documented the cause because often I still don't recognize the cause the next time I get this error. That does happen in VO as well, but far less.

    This is what I can think of quickly, of course there's much more.

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 14:07 #16223

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Dick,
    please keep in mind that Xbase and C# have completely different target groups: C# is an all-purpose language where you can do nearly everything, whereas Xbase (Clipper, VO, VFP, ...) are targeted to database application developers and hence have a large fundus of all-purpose functions.
    If you look at VB.NET instead of C# you will see that they there is already a runtime library that has many functions/methods that C# is missing (the same is true even if you compare VBScript and C# Script).
    Xbase is much nearer to Pascal than other languages (and Pascal was developed for educational purposes), whereas C# comes from C (there are some C programmers that see it as challenge to put as many functionality as possible in the minimun possible code lines, creating unreadable code full of side effects.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 15:02 #16224

  • robert's Avatar

  • robert


  • Posts: 1895
  • Dick,
    You mention a lot of topics. Some I recognize and acknowledge, others have nothing to do with C# vs VO but with the tooling (VS IDE vs VO IDE) .
    There is one topic that strongly disagree on:

    DeleteSubKey (Registry) returns Void while Bool should be the right return type

    I understand why you find this problematic. Setting up an error handler easily adds a few lines of code that distract from the real programming logic. However many years of support have taught me that most people simply do not check for return values of method/function calls.
    I have often seen code that looks like this:
    DbUseArea(...)
    DbGoTop()...
    DO WHILE ! Eof()
       .. FieldGet(..)
       DbSkip(1)
    ENDDO

    Does this look familiar ?
    NOBODY is checking the return values of DbUseArea(), DbGoTop() and DbSkip().
    And fortunately this mostly runs without a problem.
    But in case that there IS a problem, when would you detect it:
    - If the DbUseArea() fails
    - Then the DbGoTop() will also fail
    - and then Eof will return TRUE ? Or not ?
    - FieldGet() will fail
    - DbSkip() will fail

    The original point of failure is the DbUseArea(), bit since most people are ignoring its return value it is very difficult to diagnose the problem.
    They will see a loop that is not entered even though they "know" that there are records. Or the FieldGet() fails.

    Robert

    PS : EoF() will return TRUE when the current area does not have an open table, so the code will not enter the loop.
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 15:04 #16225

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Wolfgang,

    wriedmann wrote: please keep in mind that Xbase and C# have completely different target groups: C# is an all-purpose language where you can do nearly everything, whereas Xbase (Clipper, VO, VFP, ...) are targeted to database application developers and hence have a large fundus of all-purpose functions.


    I do, and that was the whole purpose of my posting: that it may sound logical to work in the bradly used C# but that a lot is missing so X# is the more logical choice. Some of the drawbacks (VS/.Net) also apply to X# but there are a few advantages in VS/.Net as well. In fact, if I would be able to edit and identify (the change dates etc) of single entities I would probably find the disadvantages and advantages about equal.

    (there are some C programmers that see it as challenge to put as many functionality as possible in the minimum possible code lines, creating unreadable code full of side effects.


    Indeed. And that is also the drawback of the widely available solutions for common problems. Even with a lot of upvotes in Stackoverflow a solution can be worse than another. I always search for the one with the minimum amount of code provided I still understand what is being done. The extra advantage of X# is that when I find a solution here for a problem I usually think, ok that must be good because it is written by someone I know (in quite some cases even personally).

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 15:09 #16226

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Robert,

    robert wrote: Dick,
    There is one topic that strongly disagree on:
    DeleteSubKey (Registry) returns Void while Bool should be the right return type


    That is a very interesting observation. I have had more of these "issues" but indeed, if you can get more information than a simple true/false which may even be misleading, in the error handler than it is easier to react accordingly.

    Never seen it like that. The better solution probably should have been a more detailed error as return value (instead of Void) but I now see the disadvantages of a boolean as return value. Thanks for that!

    Dick

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 15:19 #16227

  • robert's Avatar

  • robert


  • Posts: 1895
  • Dick,
    Registry.DeleteSubkey gives you several different exceptions depending on the cause of the problem:

    InvalidOperationException: The subkey has child subkeys
    ArgumentException: The subkey parameter does not specify a valid registry key
    ArgumentNullException: subkey is null
    SecurityException: The user does not have the permissions required to delete the key.
    ObjectDisposedException: The RegistryKey being manipulated is closed (closed keys cannot be accessed).
    UnauthorizedAccessException: The user does not have the necessary registry rights.

    I think this is very helpful

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    X# or C#? 16 Oct 2020 18:36 #16232

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 788
  • Hello Robert,

    Registry.DeleteSubkey gives you several different exceptions depending on the cause of the problem:
    I think this is very helpful


    I totally agree. But at the same time: would have been much more elegant if that message were returned as a string instead of having a void method and a necessary error handler. That is IMO one of many flaws in the design of .Net.

    Dick

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    • 2