当前位置:网站首页>Exception handling of class C in yyds dry goods inventory
Exception handling of class C in yyds dry goods inventory
2022-07-02 01:47:00 【Andy ahui】
Welcome to be my reader , I hope this article can give you some help .
Preface
During the daily coding process , The most important skill is not that you learn to use many of the latest programming techniques or make a tall system . It's when you're writing code , Handling of exceptions , Whether the system can be stable , robust .
For exception handling in C# China is through try/cath Mechanism to capture , Let's take a look at .
An exception is a runtime error in a program , It violates system constraints or application constraints , Or something unexpected in normal operation .
For example, abnormal assignment of some variables or errors during operation .
abnormal
About anomalies , stay C# Pass through try Statement and exception handling mechanism class ensure exception capture , Prevent the whole program from being reminded of exceptions due to the non capture of exceptions , Even collapse .
Unusual requirements
- try Blocks contain code that is protected from exceptions
- catch The clause section contains one or more catch Clause .( The exception handling code segment is also called exception handling subroutine )
- finally Blocks contain code to be executed in all cases , Whether there is any abnormality or not
When processing business code , Logical errors must be considered clearly at the beginning for verification , For example, judge empty , Abnormal value , Wrong value type, etc .
Secondly, through try/catch Mechanism to catch abnormal exceptions , Prevent the program from making uncontrollable errors , Leading to a rout .
Tips : Use exceptions as little as possible to catch in business programs , If the conditions are met, the exception should be handled in advance as soon as possible .<Catch() The exception handling time in will be relatively long , And it will lead to the waste of system resources ( Exceptions are thrown up in real time ).>
stay C# There are many different types of exceptions that can occur in ,BCL Many classes are defined , Each class represents a specified exception type . When an exception occurs ,CLR First create an exception object of this type , Second, find the right catch Clause to handle it .( All exception classes are derived from System.Exception class )
About catch() There are three forms , Can handle different levels of exceptions .
The first one is General exception handling
Can accept any exception , But we can't confirm the type of exception . The possible exceptions can be handled and cleaned up .
The second kind Specific exception handling
Take the name of an exception class as a parameter , An exception that matches the specified class or an exception class derived from it .
The third kind of Specific exception handling with object
A variety of exception information about exceptions can be provided , An exception that matches the specified exception or an exception class derived from it . Through the exception instance , You can get the details of the exception .
Here's a special explanation , About finally The code in , Whether the exception is caught or not , It will be executed .
stay finally Code suitable for releasing resources or subsequent processing .
Basic knowledge day has been 29 God , If you want to continue , You can pay attention to , Thank you for your support .
remarks
Life is short , I don't want to pursue what I can't see , I just want to catch what I can see .
Originality is not easy. , Pay attention .
I am a A Hui , Thank you for reading , If it helps you , Please like it 、 forward thank you .
I'm glad to be friends with you .
边栏推荐
- 6-2 vulnerability exploitation - inevitable problems of FTP
- The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
- 6-3漏洞利用-SSH环境搭建
- The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
- [Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
- Implementation principle of city selector component
- Ubuntu20.04 PostgreSQL 14 installation configuration record
- Four basic strategies for migrating cloud computing workloads
- Based on configured schedule, the given trigger will never fire
- Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation
猜你喜欢

PR second training

II Basic structure of radio energy transmission system

城市选择器组件实现原理

What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation

Ks006 student achievement management system based on SSM

Game thinking 15: thinking about the whole region and sub region Services
![[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility](/img/8b/e51867cfe9d200ac385e1d1f01e4b3.jpg)
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility

电商系统中常见的9大坑,你踩过没?

k线图形态这样记(口诀篇)

Self drawing of menu items and CListBox items
随机推荐
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
Automatically browse pinduoduo products
How can I batch produce the same title for the video?
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
Electronic Society C language level 1 32, calculate the power of 2
Six lessons to be learned for the successful implementation of edge coding
Tencent cloud techo youth dream campus trip into Wuhan University
new和malloc的区别
现货黄金分析的技巧有什么呢?
Brief introduction to the development of mobile network
II Basic structure of radio energy transmission system
Exclusive delivery of secret script move disassembly (the first time)
Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
1218 square or round
I Brief introduction of radio energy transmission technology
【LeetCode 43】236. The nearest common ancestor of binary tree
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
Is the knowledge of University useless and outdated?
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
How to debug apps remotely and online?