当前位置:网站首页>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 .
边栏推荐
- [Maya] the error of importing Maya into Metahuman
- Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
- Electronic Association C language level 1 33, odd even number judgment
- SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
- Edge computing accelerates live video scenes: clearer, smoother, and more real-time
- This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
- [IVX junior engineer training course 10 papers to get certificates] 09 chat room production
- Modeling essays series 124 a simple coding method
- 浅浅了解Servlet
- Based on configured schedule, the given trigger will never fire
猜你喜欢

We should make clear the branch prediction

Learn C language from scratch day 025 (maze)

matlab 使用 audioread 、 sound 读取和播放 wav 文件

How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?

游戏思考15:全区全服和分区分服的思考

MATLAB realizes voice signal resampling and normalization, and plays the comparison effect

II Basic structure of radio energy transmission system

分卷压缩,解压
![[rust web rokcet Series 1] Hello, world and get, post, put, delete](/img/d8/7dd5fe409d349a13128b6af554f952.jpg)
[rust web rokcet Series 1] Hello, world and get, post, put, delete

Introduction to ffmpeg Lib
随机推荐
The technology boss is ready, and the topic of position C is up to you
Based on configured schedule, the given trigger will never fire
This is the form of the K-line diagram (pithy formula)
6-3 vulnerability exploitation SSH environment construction
Architecture evolution from MVC to DDD
电子协会 C语言 1级 33 、奇偶数判断
Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
大学的知识是否学而无用、过时?
How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
There are spaces in the for loop variable in the shell -- IFS variable
Three core problems of concurrent programming
np.where 和 torch.where 用法
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
k线图形态这样记(口诀篇)
How to debug apps remotely and online?
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
Laravel artisan 常用命令
JMeter (II) - install the custom thread groups plug-in
Luogu p1775 stone merger (weakened version)