当前位置:网站首页>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漏洞利用-ftp不可避免的问题
- 跨域?同源?一次搞懂什么是跨域
- Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
- MPLS experiment operation
- We should make clear the branch prediction
- 【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
- [IVX junior engineer training course 10 papers] 06 database and services
- 游戏思考15:全区全服和分区分服的思考
- Have you stepped on the nine common pits in the e-commerce system?
- [Maya] the error of importing Maya into Metahuman
猜你喜欢

Learn basic K-line diagram knowledge in three minutes

Learning note 3 -- Key Technologies of high-precision map (Part 1)

机器学习基本概念

We should make clear the branch prediction

Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage

企业应该选择无服务器计算吗?

Three core problems of concurrent programming

【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
![[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me](/img/b8/31a498c89cf96567640677e859df4e.jpg)
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me

What is AQS and its principle
随机推荐
KS006基于SSM实现学生成绩管理系统
The technology boss is ready, and the topic of position C is up to you
Matlab uses audioread and sound to read and play WAV files
如何用一款产品推动「品牌的惊险一跃」?
[IVX junior engineer training course 10 papers] 06 database and services
遷移雲計算工作負載的四個基本策略
Raspberry pie 4B learning notes - IO communication (1-wire)
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
Brief introduction to the development of mobile network
uTools
PR second training
6-2漏洞利用-ftp不可避免的问题
[image enhancement] vascular image enhancement based on frangi filter with matlab code
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
SQLite 3 of embedded database
城市选择器组件实现原理