Giter Club home page Giter Club logo

Comments (4)

micjahn avatar micjahn commented on July 20, 2024

Please try Enum.TryParse<BarcodeFormat>("All_1D", out BarcodeFormat format);

from zxing.net.

micjahn avatar micjahn commented on July 20, 2024

It works as expected, but you have to take care of the upper case and lower case.

      [Test]
      public void Test_Enum()
      {
         BarcodeFormat format;

         Enum.TryParse("All_1D", out format);
         Assert.That(format, Is.EqualTo(BarcodeFormat.All_1D));

         Enum.TryParse<BarcodeFormat>("All_1D", out format);
         Assert.That(format, Is.EqualTo(BarcodeFormat.All_1D));

         Enum.TryParse("all_1d", true, out format);
         Assert.That(format, Is.EqualTo(BarcodeFormat.All_1D));

         Enum.TryParse("ALL_1D", true, out format);
         Assert.That(format, Is.EqualTo(BarcodeFormat.All_1D));
      }

from zxing.net.

RodBarnes avatar RodBarnes commented on July 20, 2024

Interesting. I did further testing and realized I was using an all-caps name "ALL_1D" because all of the enum names are in all-caps except for this one. Looking closer, I see that the "L" are actually lower-case in this one name.

So, it does work with the correctly cased name. However, is the use of lower-case "L" a mistake since all other names are fully upper-case? I was using a ToUpper() to force all names passed through to upper-case in an attempt to prevent mistakes. Of course, that will cause the passing of "All_1D" to fail as it becomes "ALL_1D".

from zxing.net.

micjahn avatar micjahn commented on July 20, 2024

It's not a mistake. I choose lower case because it is not a real barcode format.
You can use Enum.TryParse("ALL_1D", true, out format); in this case.

from zxing.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.