【c# – 如何获取代理】教程文章相关的互联网学习教程文章

c#-在datagrid中获取行删除事件的隐藏值(ASP Webforms)【代码】

我无法从datagrid检索不可见列的值.如果列不可见,如何获取值? 这是我的代码: 数据网格:<asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" Visible="False" /><asp:BoundField DataField="category" HeaderText="Category" /><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />行删除事件protected void dgvCategory_RowDeleting(object sender, GridViewDeleteEventArgs e)...

C#-Azure-调用Storage rest api获取列表Blob【代码】

我想做的是连接到Azure Storage Rest API列表Blob.参考:http://msdn.microsoft.com/en-us/library/windowsazure/dd135734.aspx 我尝试遵循http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx以指定授权标头,但是我收到403错误-禁止. 码:Uri address = new Uri("https://account.blob.core.windows.net/$logs?restype=container&comp=list"); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(addr...

C#获取当前路径的七种方法

//1.获取模块的完整路径。 string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //2.获取和设置当前目录(该进程从中启动的目录)的完全限定目录 string path2 = System.Environment.CurrentDirectory; //3.获取应用程序的当前工作目录 string path3 = System.IO.Directory.GetCurrentDirectory(); //4.获取程序的基目录 string path4 = System.AppDomain.CurrentDomain.BaseDirectory;//5.获取和设...

c#-根据子元素的值获取父元素【代码】

我有一个XDocument对象,试图在其中基于子元素的值获取直接父元素. 获取子元素的值没有问题,但是我一直在努力寻找仅获取父元素的正确方法.由于与XML的合作不多,我怀疑该解决方案很简单,而且我考虑得太多了. 本质上,基于以下XML,如果< Active> true< / Active>那么我想要直接的父元素(即< AlertNotification>),而没有其他元素. 先感谢您. XML的示例<?xml version="1.0" encoding="utf-16"?> <Policies xmlns:xsi="http://www.w3.org/...

c#-执行RenderTransform(缩放和平移)后,如何获取UIElement的新位置和大小?【代码】

我正在使用RenderTransform对图像执行缩放,平移和旋转.转换不是使用鼠标事件完成的,而是用户将单击一个按钮,然后图像将按固定值缩放/平移/旋转. 我的问题是,每次执行缩放,平移或旋转时,我都想确定图像的新位置/大小.因此,我在后面的代码中添加了Changed事件.问题是如何获得新的头寸/大小? 请看一下我到目前为止所做的事情: XAML:<Border x:Name="mainImageBorderCtrl" ClipToBounds="True"><Grid x:Name="imageGridCtrl"><Grid....

是否有简单的方法像C#一样在Java中定义“获取并设置”?【代码】

这个问题已经在这里有了答案: > Java and C#-like properties 5个在C#中,我可以使用如下所示的简单方法public class Dummy {public string Name { get; set; } }但是,如果我使用Java做同样的事情,我必须像下面这样public class Dummy {private String _name;public void setName(String value) {this._name = value;}public String getName() {return this._name;} }因...

c#-企业库异常:尝试获取ICacheManager类型的实例的密钥时发生激活错误?【代码】

使用.net 3.5和Enterprise Library 5.0. 从我的研究中,我在这里发现了类似的问题:Activation error occured while trying to get instance of type ICacheManager, key “Cache Manager” ***此解决方案无法解决我的问题. 我似乎无法弄清楚,我的配置应该正确设置,但是仍然会出现异常?有人有类似的问题吗? 我建议在调用缓存管理器时添加cacheManager和引用:using Microsoft.Practices.EnterpriseLibrary.Caching; using Microso...

c#-无法在ASP.Net中获取当前用户IP【代码】

我试图在我的AP.Net网站上获得访客IP地址.string sd = HttpContext.Current.Request.UserHostAddress;它应该返回一个有效的IP.但是只返回::1我不明白这是什么样的结果.谁可以帮我这个事?解决方法::: 1是有效的IP地址.这是IPv6回送地址. (更熟悉的)IPv4等效项是127.0.0.1.

c#-获取LINQ之前和之后的x个元素的子集【代码】

我有一个列表,我需要它的一个子集,该子集具有当前for循环中的5个先前元素和之后的5个元素,因此总共有10个元素的列表.忽略循环中的当前项目. 我目前正在实现以下目标:var currentIndex = myList.ClassName.FindIndex(a => a.Id == plate.Id); var fromIndex = currentIndex - 5; if (fromIndex < 0) fromIndex = 0; var toIndex = currentIndex + 5; if ((myList.ClassName.ElementAtOrDefault(toIndex) == null))toIndex = myList...

c#-获取设备的MAC地址【代码】

我正在写一个Windows Phone 8.1应用程序,它可以发现附近的Bluetooth Low Energy设备.foreach (DeviceInformation device in devices) {BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(device.Id); }一切正常,但是bleDevice.BluetoothAddress属性包含ulong类型,而我需要一个字符串类型,其格式类似于Mac Address. 例:bleDevice.BluetoothAddress: 254682828386071 (ulong) Desired Mac Address: D1:B4:EC:14:2...

c#-获取实现类型的具体属性【代码】

鉴于以下课程public Foo {public Foo() {this.Bar = new Bar();}public IBar Bar{ get; set;} }public Bar : IBar {// implemented properties}如何使用反射获得Foo属性Bar的具体实现?instance.GetType().GetProperty("Bar").PropertyType仅产生接口.解决方法:如果您尝试获取实现IBar的类型,则应获取其值并采用该类型:var type = instance.GetType().GetProperty("Bar").GetValue(instance,null).GetType()

c#-获取QuickFix / n的会话属性(用户名和密码)【代码】

我已经将我的用户名和密码放在FIX配置文件中.因此,我必须认为我应该能够从某些内部变量(例如会话变量或SessionSetting变量或session.SessionDataDictionary或其他变量)获取用户名和密码.但是,我没有找到直接从内部变量获取用户名和密码的解决方案.[SESSION] BeginString=FIX.4.4 SenderCompID= xxxxx Username= xxxx Password= xxxx从逻辑上讲,这可能是非常可行的.但是,没有人建议这样做,或者我还没有在Google上看到任何人这样做.我...

C#-如何从ews联系人获取电子邮件地址【代码】

即时通讯使用此代码从Outlook中获取联系人:foreach (var v in svc.FindItems(WellKnownFolderName.Contacts,new ItemView(20))){Contact contact = v as Contact;ContactGroup contactGroup = v as ContactGroup;if (contact != null){ Console.WriteLine("Contact: {0} <{1}>",contact.DisplayName,contact.EmailAddresses[EmailAddressKey.EmailAddress1]);}}我需要获取电子邮件指示(xxx@xxx.xx),但我在电子邮件地址字段中收到...

c#-在Simple Injector中使用运行时数据获取实例【代码】

我有一个基于数据库中的用户配置来构建其用户界面的应用程序.我创建了一个名为IAction的接口,它看起来像这样;public interface IAction {ActionType ActionType { get; }bool CanExecute { get; }void Configure(ActionConfigDto config);void Execute(); }诸如AddItemAction之类的实现将如下所示;public class AddItemAction : IAction {public ActionType ActionType {get { return ActionType.AddItem; }}// Rest of implemen...

c#-使用naudio获取1秒音频文件的分贝【代码】

我想使用naudio计算任何.wav文件中1秒的分贝.这是我的代码:WaveFileReader reader = new WaveFileReader(@"C:\Users\Admin\Desktop\result.wav");int bytesPerMillisecond = reader.WaveFormat.AverageBytesPerSecond / 1000; //byte[] buffer = new byte[reader.Length];//int read = reader.Read(buffer, 0, (int)reader.Length);TimeSpan time = new TimeSpan(0, 0, 1);int bytesPerSecond = (int)time.TotalMillis...