C#中的友元程序集

C# 友元程序集 使用友元程序集可以将internal成员提供给其他的友元程序集访问。程序集FriendTest1.dll程序集FriendTest2.dll调用。 阅读详情

在C#中,有public,private,internel和protected集中权限限定符,其中跨程序集编程时,经常出现不想让A程序对外public,又想让B程序对A具有访问权限,友缘程序集的作用就是解决这个问题。

新建项目A和B,分别新建类CA和CB,访问权限均设置为interl,这个时候,只有内部程序集才能访问内部类和方法属性,也就是说B绝对不能访问到A。

如何让项目B中的CB类能访问到CA类呢?
首先,在类CB的定义文件中System.Runtime.CompilerServices; 命名空间,

然后在文件中使用InternalsVisibleTo] 特性将A添加为B的友缘程序集,语句如下:

[assembly: InternalsVisibleTo("TestA")]

注: 该命令也可以放在项目的 AssemblyInfo.cs 文件中,且该文件中已经添加了相应的命名空间。

RT-Thread Studio使用笔记(四):带片外Flash(W25Q128)的OTA(YModem) 前言 在学习OTA之前,请先参考上两篇博客写的关于SPI设备及W25Q128的使用方法,传送门: https://blog.csdn.net/tigerots/article/details/107423633 https://blog.csdn.net/tigerots/article/details/107933991 如何使用OTA 一. 制作BootLoader 打开Bootloader 在线获取地址,注册,并根据RT-thread官方文档生成BootLoader,官方文档已经写的很清楚,再此 阅读详情

相关推荐

PCB压合原理与工艺全流程深度解析

PCB压合是多层印制电路板制造中的核心工序,其本质并非简单物理叠加,而是高分子树脂流动、玻璃布应力释放、铜箔热膨胀及界面能调控的协同过程。理解压合原理,需掌握温度-压力-时间三维曲线动态关系;优化工艺流程,须兼顾叠板精度、热压参数匹配与冷却策略;关键影响因素如半固化片(PP)选型、铜箔表面处理、设备温场均匀性、结构对称性、环境湿度及操作手法,共同决定层间结合力、翘曲度与孔壁质量。本文围绕PCB压合原理、工艺流程、关键影响因素三大维度展开,融合IPC标准、实测数据与产线案例,为工艺工程师、NPI人员及设备维护

weixin_29191081的博客 253

C#友元函数与友元类

在C#中,并没有像C++那样的友元函数和友元类的直接语法支持。C#中的访问控制是通过public、private、protected等访问修饰符来实现的,而不是通过友元的概念。

sunyao1314的博客 1254

告别设备管理器混乱!3分钟学会用STM32CubeMX+Zadig定制专属虚拟串口名称

本文详细介绍了如何利用STM32CubeMX和Zadig工具,为STM32的USB虚拟串口(VCP)定制专属设备名称,从而彻底解决多设备连接时设备管理器端口混乱的难题。通过修改产品字符串描述符并替换驱动,开发者可以在设备管理器中清晰识别不同开发板,显著提升调试效率,尤其适用于多设备协同的竞赛或项目开发场景。

a2b3c4d5e的博客 477

C# 的“友元”类实现 Builder 模式

友元是 C++ 中的概念,包含友元函数和友元类。被某个类声明为友元的函数或类可以访问这个类的私有成员。友元的正确使用能提高程序的运行效率,但同时也破坏了类的封装性和数据的隐藏性,导致程序可维护性变差。因此,除了 C++ 外很难再看到友元语法特性。 提出问题 但是友元并非一无是处,在某些时候确实有这样的需求。举例来说,现在我们需要定义一个 ...

weixin_34233856的博客 919

sdio wifi 移植

介绍 简单来说,sdio起源自sd标准,顾名思义就是sd的IO接口(interface)的意思,更具体的说明,sd本来是记忆卡的标准,但是现在也可以把SD卡拿来插上一些外围设备接口使用,这个就是就叫做sdio。 而且sdio本身是一种相当单纯的技术,通过sd的IO引脚来连接外部外围,并且通过sd的IO数据接位与外围传输数据,而且sd协会也推出很完整的sdio stack 驱动程序,使得sdio外围得开发与应用变得非常热门 这里我们要移植的是RTL8822cs的sdio WiFi 模块,将其移植到rk3

Enosji的博客 9609

使用MLP解决OCR问题(OpenCV)(下)

分类模型:        分类模型涉及的一个比较关键的问题就是输出的10维向量是如何与具体的类别挂钩的。实际上:10维向量的每一位都代表一类,在对于训练集的表达中,如果输入数据是0,则10维向量的第一位赋值为1,其余均为0。即0对应[1,0,0,0,0,0,0,0,0,0]。MLP模型训练完成后,就需要对用户输入的数据所属类别进行判定。这时得到的输出数据基本不可能是正好的所属类为1,其他位置为0

qq_18515405的专栏 1906

C#:友元程序集

C#中的访问修饰符Internal可以说是介于Public和Private之间,可以使类型在同程序集中可以被互相访问。但有时会有这样的需求,我们希望一个程序集中的类型可以被外部的某些程序集可以访问,这时当然不能设置成Public,否则可以被所有的外部程序集访问。要达到上述要求我们可以使用友元程序集。 下面用一个简单的例子来介绍下友元程序集。 1 在一个解决方案中创建两个类库项目TestA和...

weixin_34127717的博客 256

《时序分析、时序约束和时序收敛》专栏的说明与导航

《时序分析、时序约束和时序收敛》专栏的说明与导航(建议阅读)。

孤独的单刀 14万+

C#友元程序集

internal:对友元程序集和内部可见.我们可以利用这一点,使我们开发的类库更加地安全.比如,你不喜欢你开发的ClassLib( DLL ),被其他公司或团队使用,就可以在使用internal , 当然还要加上友元程序集的相关知识.上代码:TestFrendsAbb 类库ToolsBytesusingSystem; usingSystem.Collections.Gen...

weixin_34233856的博客 167

微信小程序 - 详细解决web-view公众号文章或第三方网站分享转发后打开失败,页面显示“无法打开该页面,不支持打开“、“页面不存在“报错提示,苹果IOS系统手机打开是空白页,安卓手机系统会有提示!

微信小程序,公众号文章,第三方H5网页,内嵌网站分享后打不开,web-view,页面分享,小程序里公众号文章转发后无法打开,白屏,页面空白什么都没有,不支持打开,无法打开该页面,页面不存在,业务域名配置好了还是不行,公众号和小程序已经关联,iOS端苹果真机打开空白页,安卓手机,页面分享后,用户打不开提示错误,提示页面不存在,如何解决页面提示无法打开该页面,微信小程序web-view无法打开该页面不支持打开的解决方法,无法打开该页面不支持打开,最新详细解决方案,分享之后无法打开页面,提示无法打开该页面,不支持

🏆 前端领域优质创作者 1万+

LVGL 蜂巢气泡菜单(Hex Menu)

h。

摸鱼专家 176

友元程序集(C# 和 Visual Basic)

友元程序集(C# 和 Visual Basic) Visual Studio 2013 “友元程序集”是一种能够访问其他程序集的 Friend (Visual Basic) 或 internal (C#) 类型和成员的程序集。 如果将程序集指定为友元程序集,则不再需要将类型和成员标记为公共,以使其他程序集可以访问它们。 在以下情况下,使用友元程序集尤其方便: 在单...

weixin_33670786的博客 226

「深度学习之优化算法」笔记(二)优化算法的分类

但是由于生物的局限性,人们所创造出的算法也会有局限性:我们所熟知的生物都生存在三维空间,在这些环境中,影响生物生存的条件比较有限,反应到算法中就是这些算法在解决较低维度的问题时效果很好,当遇到超高维(维度>500)问题时,结果可能不容乐观,没做过实验,我也不敢乱说。当然,他们的目的不是在最佳狩猎位置集合,他们的目的是在过去的途中看是否能发现更加好的狩猎位置,去往已经到过的狩猎地点再次狩猎是没有意义的,因为每个位置获取食物的难易程度是固定的。如果他们的策略是“不跟随最优解”,那么他们的策略是什么呢?

quanzhan_King的博客 1371

如何:创建签名的友元程序集(C# 和 Visual Basic)

如何:创建签名的友元程序集(C# 和 Visual Basic) Visual Studio 2013    本示例演示了如何将友元程序集和具有强名称的程序集一起使用。 这两种程序集必须都使用强名称。 尽管本示例中的两种程序集使用了相同的密钥,但您可以对这两种程序集使用不同的密钥。 在 Visual Studio 中创建签名的程序集和友元程序集 打...

weixin_34356310的博客 253

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

8.C#友元程序集----可访问性相关

在一个团队或者公司中,一个人开发出来的程序集中的类的可见性有public,private和internal, public:对所有程序集可见,就是说如果拿到程序集.DLL文件,那么类就被公开了。 private:对程序集内部可见,就是自己定义来自己用,不公开。 internal:对友元程序集和内部可见,是我的朋友才能用这个类。 好了,如果一个程序集中要调用另外一个程序集,但是要被...

weixin_30896763的博客 221

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

C# 友元程序集(Visual Studio 2022)

在 Visual Studio 2022 中为 C# 程序集添加友元程序集的方法。

2303_77328849的博客 708

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

C# - 指定友元程序集

前序:为了解决在程序集A中定义了受保护(internal)类型,然后需要在额别特殊的其他程序集B中正常访问,使用 InternalsVisibleToAttribute(String) 构造函数 实现。在程序集A的代码根目录创建文件:Properties/AssemblyInfo.cs。创建AssemblyInfo.cs文件。在程序集B中即可正常访问。

枫叶的博客 214

C# 之友元程序集

C#中的访问修饰符Internal可以说是介于Public和Private之间,可以使类型在同程序集中可以被互相访问。但有时会有这样的需求,我们希望一个程序集中的类型可以被外部的某些程序集可以访问,这时当然不能设置成Public,否则可以被所有的外部程序集访问。要达到上述要求我们

zyy5411的专栏 958
上一篇: Python中的可变,不可变对象;值类型,引用类型;浅拷贝,深拷贝理解
下一篇: C#中的ref和out类型参数
河流儿
博客等级 码龄11年 45粉丝 77原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值