【c# – 缩短的整数数组】教程文章相关的互联网学习教程文章

c# – 使用VirtualAlloc从字节数组运行程序?【代码】

我正在使用C#中的应用程序SFX / Protector,我希望受保护的程序集从字节数组执行而不是将其写入硬盘,以便更加难以进行逆向工程. 我有一个字节数组内的程序(有一个有效的入口点),我想执行它.我在这个网站上发现了一个类似的问题我怎么能这样做,我知道这可以使用下面的代码片段来完成,但有人可以指导我如何使用这个从字节数组运行程序? 从技术上讲,他下面的代码让我这样做:using System; using System.Collections.Generic; using S...

如何使用swig和C#处理字符串数组?【代码】

我的C类有一个名为init的方法:int init(int argc, char **argv)另外,我有一个回调:void callback(int num, char **str)我的问题是Swig生成了一个奇怪的类SWIGTYPE_p_p_char.cs,没有像我预期的那样的字符串[].请指教.解决方法:SWIG有一些用于将数组传递给函数的类型映射,在arrays_csharp.i中.但是没有一个用于char * INPUT []但是我们可以调整类型映射来做你想要的:%module test%include <arrays_csharp.i>CSHARP_ARRAYS(char *,...

c# – 在字符串数组上查找Any方法【代码】

特定string[] stringArray = { "test1", "test2", "test3" };然后返回true:bool doesContain = stringArray.Any(s => "testa test2 testc".Contains(s));我的最终目标是制作一个linq表达式树.问题是我如何获得“任何”的方法信息?以下方法无效,因为它返回null.MethodInfo info = typeof(string[]).GetMethod("Any", BindingFlags.Static | BindingFlags.Public);进一步说明: 我正在创建搜索功能.我使用EF,到目前为止使用linq表达...

将Datatables POST数组转换为C#Model【代码】

我使用datatables.net结构向asp mvc发送数据如下所示draw:1 columns[0][data]:first_name columns[0][name]: columns[0][searchable]:true columns[0][orderable]:true columns[0][search][value]: columns[0][search][regex]:false columns[1][data]:last_name columns[1][name]: columns[1][searchable]:true columns[1][orderable]:true columns[1][search][value]: columns[1][search][regex]:false order[0][column]:0 order[...

c# – 以小端方式整数到字节数组(泛型函数)【代码】

我有这个方法来转换长到小端字节数组public static byte[] UnsignedIntegerToLEByteArray(ulong value) { // Value in bytes... in your system's endianness (let's say: little endian)byte[] bytes = BitConverter.GetBytes(value);// If it was big endian, reverse itif (!BitConverter.IsLittleEndian)Array.Reverse(bytes); return bytes; }我的目标是将它用于短路数据类型,如int,short等.请看这里:byte a = 0xAA; usho...

c# – Azure搜索中的包含/数组(预览)【代码】

我正在使用新的(预览)Azure搜索SDK(information here).我正在使用oData表达式语法使用$filter参数构建我的搜索查询,并且我希望能够将一组id引用到端点. brandId字段位于我的Azure搜索索引中,可搜索,可过滤,可排序和可分页.理想情况下,我希望能够做到以下几点:http://host/service/Products?brands=["1","2"](See specification here题为“复杂和收集文字”一节) 我无法弄清楚用什么语法来包含$filter查询中的集合文字语法.所以我现...

c# – 超出范围异常2D数组到类型Int的列表【代码】

为什么我在这里得到超出范围的例外? 该方法将int [] []数作为参数. 我的代码:List<int> myList = new List<int>();for (int i = 0; i < numbers.GetUpperBound(0); i++){for (int z = 0; z < numbers.GetUpperBound(1); z++){myList.Add(intervals[i][z]);}}我尝试谷歌它,但我没有任何胶水.解决方法:正如评论中提到的那样,它是一个锯齿状数组,所以问题中的代码不起作用.我现在循环使用数组的方式在代码中看起来像这样:List<int>...

c# – Newtonsoft.JSON:JSON列表和数组的处理方式不同【代码】

参见英文答案 > Explanation for ObjectCreationHandling using Newtonsoft JSON? 2个给出以下代码:public class ColorList {public List<string> Colors = new List<string>(new string[1] { "#eeeeee"}); } public class ColorArray {public string[] Colors = new string[1] { "#eeeeee"}; }public class Program {public static void Main(){string json = "{Colors:['#abc','#123']}";...

c# – 以编程方式创建已知尺寸,类型和长度的数组【代码】

我正在尝试解析一个IDX文件(用于存储几种不同类型的多维数据).我已成功解码标题,告诉您数据的类型(无符号字节,有符号字节,短,整数,浮点数或双精度),维数和这些维的大小.但是,有了这些信息,我无法想到或找到一种方法以编程方式声明具有上述参数的数组. 例:Type type = getDataType(magicBytes); int numOfDimensions = getNumberOfDimensions(magicBytes); int[] sizeOfDimensions = getSizeOfDimensions(numOfDimensions, inputSt...

c# – 基于数组生成动态LINQ表达式【代码】

我正在使用LINQ exprssion来查询客户并按州名过滤它们.我有以下查询工作正常,直到我在statesArray中有4个项目.public void GetCustomersForSelectedStates(string[] statesArray) {var customers = _repo.GetAllCustomers();var filteredCustomers = from CUST in customersjoin ST in States on CT.Tag_Id equals ST.Id where CUST.ID == customer.ID && (ST.Name == statesArray[0] ||ST.Name ==statesAr...

c# – 在csv文件中使用字符串拆分和数组的LINQ问题【代码】

鉴于以下代码:var query = from line in ClientCount()let aLine = line.Split(",")where aLine.GetValue(1) != 0select aLine;要查询csv文件,aLine.GetValue(1)将获得.csv文件中的第1行(0之后)或第1个字符串,例如: abc,def 因此得到def?我想得到def,但后来我也想在这样的文件中选择title2,如下所示: 标题,标题2 abc,def 我怎样才能做到这一点? 顺便说一下,我知道这有LINQ To CSV,但我自己也是这样做的. 谢谢解决方法:所以,如...

c# – 如何使用string.Join将Jagged数组与分隔符连接?【代码】

我怎样才能解决下面的字符串连接错误.我将int值转换为字符串值但发生错误….查看Join方法using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data;namespace SortArrayYusuf {class Program{static void Main(string[] args){//int[] array;//using (DataTable table = GetTable())//{// array = (from DataRow row in table.Rows// select// (from...

c# – 将空数组序列化和反序列化为Dictionary / object【代码】

我正在开发一个必须与PHP 5.2.13服务器应用程序通信的Silverlight 3应用程序.我们正在使用JSON.NET来完成这项工作,但我在使用词典方面遇到了一些问题. 我正在做一些实验并尝试反序列化包含Dictionary的对象:public Dictionary<string, Block> Table {get { return m_table; }set { m_table = value; } }C#序列化正确,我很满意,但在PHP方面,当序列化具有空表的等效对象时,它将无法正常工作.$this->Table = array();问题是,显然,空数...

C#.NET客户端使用返回哈希数组的外部PHP SOAP Web服务的问题【代码】

我正在编写一个需要调用外部Web服务的.NET Web应用程序.我提供的文档包括PHP中的代码示例. 我可以使用提供给我的WSDL地址在VS2010中成功创建Web引用,并且使用fiddler我可以看到预期的XML正在发送和接收.但是,.NET似乎在解析返回的XML时遇到问题. 我正在处理的最简单的Web服务只接受一个用户名数组,并且意味着返回一些嵌套的用户哈希数组(每个用户拥有自己的数组名,类型等字段)和一组错误(对于任何用户名)那不匹配).我在’PHP-ish’...

Marshal C#类数组作为结构数组到C【代码】

这是我的代码:[StructLayout(LayoutKind.Sequential, Pack = 1)] public struct Foo {UInt32 StartAddr;UInt32 Type; }[DllImport(DllName, EntryPoint="_MyFunc", CallingConvention = CallingConvention.Cdecl)] static extern unsafe IntPtr MyFunc([MarshalAs(UnmanagedType.LPArray)] Foo[] Foos);List<Foo> Foos = new List<Foo>(); Foo1 = new Foo(); Foo1.StartAddr = 1; Foo1.Type = 2; Foos.Add(Foo1); MyFunc(Foos.ToA...