常用例程的最佳做法

编程入门 行业动态 更新时间:2024-10-28 17:16:11
本文介绍了常用例程的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

放置将被广泛使用的通用例程的最佳实践是什么?迄今为止,我倾向于在每个项目中都简单地拥有一个ModGlue.vb文件,在该文件中我需要放置任何文件,但是在项目之间移动类需要从ModGlue中查找并​​复制适当的内容,这有些乏味并且会如果没有更好的策略,我就会变得越长. 一些通用例程是这样的:

What is the best practice for placing general-purpose routines which will be widely used? To date, I''ve tended to simply have a ModGlue.vb file in each project, where I throw any that I need, but moving classes between projects requires locating and copying in the appropriate stuff from ModGlue, which is somewhat tedious and will become moreso the longer I go without a better strategy.Some of the general-purpose routines are things like:

Function Byt(ByVal v as Integer) As Byte<br /> Return CByte(v and 255)<br />End Function<br /><br />Function HexArr(ByVal dat() as Byte) As String '' Returns hex representation of array<br /><br />Function ByteString(ByVal dat() as Byte, ByVal Length As Integer) As String '' Converts bytes to string (by character code)<br /><br />Sub Zap(ByRef it as iDisposable)<br /> Dim oldIt as iDisposable<br /> oldIt = it<br /> If oldIt IsNot Nothing then<br /> oldIt.Dispose<br /> Threading.Interlocked.CompareExchange(it, Nothing, oldIt)<br /> EndIf<br />End Sub

在许多情况下,sorta应该是.NET框架的一部分,但不是.在将一个类从一个项目复制到另一个项目而又不会导致多余或重复的方法结束时,确保引入必要功能的最佳方法是什么?

In many cases, things that sorta should have been part of the .Net framework, but aren''t. What''s the best way to make sure that the necessary functions get brought in when copying a class from one project to another, without ending up with extraneous or duplicated methods?

推荐答案

构建一个导入到所有项目中的dll. Build a dll you import into all your projects.

更多推荐

常用例程的最佳做法

本文发布于:2023-11-04 11:19:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:例程   做法   常用

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!