Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025

      A week of hell with my Windows 11 PC really makes me appreciate the simplicity of Google’s Chromebook laptops

      June 1, 2025

      Elden Ring Nightreign Night Aspect: How to beat Heolstor the Nightlord, the final boss

      June 1, 2025

      New Xbox games launching this week, from June 2 through June 8 — Zenless Zone Zero finally comes to Xbox

      June 1, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

      June 1, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025
      Recent

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025

      A week of hell with my Windows 11 PC really makes me appreciate the simplicity of Google’s Chromebook laptops

      June 1, 2025

      Elden Ring Nightreign Night Aspect: How to beat Heolstor the Nightlord, the final boss

      June 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: A Little Extra Padding

    CodeSOD: A Little Extra Padding

    January 5, 2025

    Today’s anonymous submitter supplies us with a classic antipattern: padding via switch:

    string TransactionOrder = (string)dr["TransactionOrder"].ToString().Trim();
    
    switch (TransactionOrder.Length)
    {
            case 1:
                    TransactionOrder = "000" + TransactionOrder;
                    break;
            case 2:
                    TransactionOrder = "00" + TransactionOrder;
                    break;
            case 3:
                    TransactionOrder = "0" + TransactionOrder;
                    break;
            default:
                    TransactionOrder = TransactionOrder;
                    break;
    }
    

    There’s not much to say here, as we’ve seen this before, and we’ll see it again. It’s wrong, it’s not how anything should be done, yet here it is, yet again. In this case, it’s C#, which also has a lovely set of built-in options for doing this, making this code totally unnecessary.

    Hostinger

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Hostinger
    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to Create Partitions in Linux Using fdisk Command
    Next Article Microsoft Bing is trying to spoof Google UI when people search Google.com

    Related Posts

    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 1, 2025
    Artificial Intelligence

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Microsoft emergency update fixes a Windows 11 bug removing Copilot app

    Operating Systems

    Server-side error occurred while processing Appium-server

    Development

    Adaptive Attacks on LLMs: Lessons from the Frontlines of AI Robustness Testing

    Development

    Mental Models and Labels: A Guide for UX Beginners

    Development
    Hostinger

    Highlights

    Development

    Microsoft Uncovers Critical Flaws in Rockwell Automation PanelView Plus

    July 4, 2024

    Microsoft has revealed two security flaws in Rockwell Automation PanelView Plus that could be weaponized…

    Interpreting and Improving Optimal Control Problems With Directional Corrections

    April 2, 2025

    Enhance Your Workflow: AI Design Plugins for Figma and Adobe Express

    July 2, 2024

    Anchoreum: A New Game for Learning Anchor Positioning

    November 12, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.