小编kev*_*evp的帖子

从字符串中提取数字以创建仅数字字符串

我得到了一些格式不佳的数据,需要从字符串中提取数字.我不确定最好的办法是什么.数字可以是任何长度.

string a = "557222]]>";
string b = "5100870<br>";
Run Code Online (Sandbox Code Playgroud)

知道我能做什么所以我会得到这个:

a = "557222"
b = "5100870"
Run Code Online (Sandbox Code Playgroud)

谢谢

解决方案是c#抱歉.编辑了问题以获得该标记

.net c# regex string

10
推荐指数
5
解决办法
5万
查看次数

将字符串数据写入MemoryMappedFile

我在这里关注本教程

我很难弄清楚如何获取字符串"这是一个测试消息"存储在内存映射文件中,然后将其拉出另一端.该教程说要使用字节数组.原谅我,我是新手,先尝试自己.

谢谢,凯文

##Write to mapped file

using System;
using System.IO.MemoryMappedFiles;

class Program1
{
    static void Main()
    {
        // create a memory-mapped file of length 1000 bytes and give it a 'map name' of 'test'
        MemoryMappedFile mmf = MemoryMappedFile.CreateNew("test", 1000);
        // write an integer value of 42 to this file at position 500
        MemoryMappedViewAccessor accessor = mmf.CreateViewAccessor();
        accessor.Write(500, 42);
        Console.WriteLine("Memory-mapped file created!");
        Console.ReadLine(); // pause till enter key is pressed
        // dispose of the memory-mapped file object and …
Run Code Online (Sandbox Code Playgroud)

.net c# memory-mapped-files

5
推荐指数
1
解决办法
2万
查看次数

跳过读取某个父节点内的 xml 元素

我正在使用 xmlreader.read() 读取 xml gps 数据。我想输出不在线元素内的所有坐标点。下面包含在文件中,我想排除列出的坐标。

<place>
  <desc>home</desc>
  <line>
      <coordinate>123,123,123</coordinate>
      <coordinate>1223,1223,22123</coordinate>
  </line>
</place>
Run Code Online (Sandbox Code Playgroud)

这是我想要输出和处理的有效坐标的示例(全部位于同一文件中):

<place>
   <desc>home</desc>
   <point>
      <coordinate>123,123,123</coordinate>
   </point>
</place>
Run Code Online (Sandbox Code Playgroud)

区别在于,一个是线对象的一部分,另一个是点。我目前有这段代码,它抓住了一切。

            while (lxmlReader.Read())
            {

                    if (lxmlReader.NodeType == XmlNodeType.Element)
                    {
                        if (lxmlReader.Name == "coordinate")
                        {
                            rtxtOutput.Text += "\r\nElement Name: " + lxmlReader.Name.ToString();
                            rtxtOutput.Text += " Value: " + lxmlReader.ReadInnerXml().ToString();
                        }
                    }                   
            }
Run Code Online (Sandbox Code Playgroud)

.net c# xml kml

0
推荐指数
1
解决办法
1371
查看次数

这个简单的C++ DLL在C#中不起作用

我一直在努力研究c ++中需要运行的c ++代码.我浏览了这个DLL教程,在我的c#app中使用它时遇到了麻烦.我将在下面发布所有代码.

我收到此PInvokeStackImbalance错误:'调用PInvoke函数'frmVideo :: Add'使堆栈失衡.这很可能是因为托管PInvoke签名与非托管目标签名不匹配.检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配.

凯文,一如既往地谢谢

DLLTutorial.h

#ifndef _DLL_TUTORIAL_H_
#define _DLL_TUTORIAL_H_
#include <iostream>

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

extern "C"
{
   DECLDIR int Add( int a, int b );
   DECLDIR void Function( void );
}

#endif
Run Code Online (Sandbox Code Playgroud)

DLLTutorial.cpp

#include <iostream>

#define DLL_EXPORT

#include "DLLTutorial.h"


extern "C"
{
   DECLDIR int Add( int a, int b )
   {
      return( a + b );
   }

   DECLDIR void Function( void )
   {
      std::cout << …
Run Code Online (Sandbox Code Playgroud)

c# c++ dll pinvoke

0
推荐指数
1
解决办法
735
查看次数

标签 统计

c# ×4

.net ×3

c++ ×1

dll ×1

kml ×1

memory-mapped-files ×1

pinvoke ×1

regex ×1

string ×1

xml ×1