我有一些文字,

我想移动variable2,var3和var4,以便所有四个变量对齐在一起.我可以用肉眼选择列CTRL-V j j w.但之后如何重新加入或删除variable2,var3和var4前面的额外空格?
请注意,移动变量1不是一个选项,因为有多行与variable1对齐.我也不能使用插件.
有没有使用任何插件,通过基本的vim命令更简单的方法吗?
谢谢.
我有以下变量:
string str1 = "1";
string str2 = "asd";
string str3 = "3.5";
string str4 = "a";
Run Code Online (Sandbox Code Playgroud)
现在我需要找到每个字符串的数据类型,即如果删除引号则可以转换的数据类型.以下是我希望每个变量转换为:
str1 - 整数
str2 - 字符串
str3 - 双
str4 - char
注意:如果字符串有单个字符,它应该是char,尽管字符串可以有单个字母,我限制它.
仅供参考:这些值是从DataGrid获得的,我手动输入值.所以一切都变成了一个字符串.有没有办法做到这一点?
考虑一下代码,
Type t0 = Type.GetType("System.Drawing.dll");
Type t1 = Type.GetType("System.Drawing.Font");
Run Code Online (Sandbox Code Playgroud)
这里为了找到"System.Drawing.Font"的类型,需要程序集"System.Drawing.dll".如何使用它.?
即如果我这样做,那么t0的值不会为空.
考虑我是一个dll,proj.dll,我需要找到dll中存在的类Class1的类型.
我在Android中尝试了一个简单的文件写程序.
try
{
//File f1=new File("/sdcard/Prag.txt");
File f1=new File("J:\\Prag.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(f1,true));
out.write("Pragadheesh" + "\n");
out.close();
} catch (IOException ioe)
{ioe.printStackTrace();}
Run Code Online (Sandbox Code Playgroud)
但是例外情况正在受到打击.我怎样才能解决这个问题?
[编辑]:我试过File f1=new File(Environment.getExternalStorageDirectory() + "//Prag.txt");
并且f1值= /mnt/sdcard/Prag.txt但仍然会遇到异常.我在清单文件中也更改了权限
[解决方案]根据Krishnabhadra的回复,我必须确保你的SD卡没有安装在PC上
我在网页上有一张图片.我想将四面图像转换为六面图像.即裁剪边缘并将图像转换为六边形.
如何在我的服务器端使用PHP ImageMagick/GD来完成它.我正在使用XAMPP服务器来构建示例网页.或者通过使用img样式属性,有更好的方法来使用Javascript/CSS.
我是 Ruby 新手,并在此链接上尝试了几个示例。
说,我有两个数组
Array1: ["square", "circle", "triagle"]
Array2: ["red", "blue"]
Run Code Online (Sandbox Code Playgroud)
我想创建一个地图,例如,
[{:shape=>"square", :color=>"red"}]
[{:shape=>"square", :color=>"blue"}]
[{:shape=>"circle", :color=>"red"}]
[{:shape=>"circle", :color=>"blue"}]
[{:shape=>"triangle", :color=>"red"}]
[{:shape=>"triangle", :color=>"blue"}]
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的代码。
def processArray6(array1, array2)
newMap = [array1].map do |entry|
{
shape: entry,
color: "abc" # Should write another for-loop here to loop over array2
}
end
end
array1 = ["square", "circle", "triangle"]
array2 = ["red", "blue,"]
p processArray6(array1, array2)
Run Code Online (Sandbox Code Playgroud)
上述代码的输出:
[{:shape=>["square", "circle", "triangle"], :color=>"abc"}]
Run Code Online (Sandbox Code Playgroud)
我不太确定如何遍历array2。
我来自 Java 背景,仍然试图了解如何从函数返回整个地图以及如何处理数组的每个元素并创建地图。
在C#中,我使用结构创建了ArrayList.所以它创建了多维数组列表.
public struct ParameterValues
{
public ArrayList al;
};
ArrayList alCombined = new ArrayList();
for(int i=0; i < CONDITION , i++)
alCombined.Add(obj.pValue.al);
Run Code Online (Sandbox Code Playgroud)
尺寸ArrayList alCombined取决于条件.如果它是1,则创建1-D arraylist.其他多维Arraylist正在创建.
现在为了访问alCombined的元素,我正在对它进行类型转换和访问,例如
(((ArrayList)al[i])[j])
Run Code Online (Sandbox Code Playgroud)
但是如果它是一维的arraylist,那么因为无法将类型转换为Arraylist而发生错误.
所以我需要一个解决方案,或者如何找到它的单/多维arraylist.仅供参考:它不应该依赖于CONDITION变量.如果d条件不止一个,那么它肯定是多维的.
提前致谢.
考虑我有一个窗口应用程序,在Visual Studio 2005中开发,有一个按钮.
当按钮被点击第三次(或第n次)而不是第一次时,我需要使用"运行到光标"/调试.我怎样才能做到这一点.?
考虑这是一个示例代码.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace breakPoint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
textBox1.Text += "hi ";
textBox2.Text += "hello ";
textBox3.Text += "bye ";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我第n次单击按钮时,我需要在"textBox1.Text"行插入断点.
如何编写以下方法的代码,以便可以在NUnit中进行测试?怎么处理Hashtable?
public DataSet MySampleMethod(int param1, string param2, Hashtable ht)
{
if(ht==null)
{
ht = new Hashtable();
}
ht.Add("testKey","testData");
DataSet ds = new DataSet();
ds.Tables.Add();
ds.Tables[0].Columns.Add("Column1");
ds.Tables[0].Columns.Add("Column2");
ds.Tables[0].Columns.Add("Column3");
DataRow dr = ds.Tables[0].NewRow();
dr["Column1"] = "My column 1";
dr["Column2"] = "My column 2";
dr["Column3"] = "My column 3";
ds.Tables[0].Rows.Add(dr);
DataRow dr1 = ds.Tables[0].NewRow();
dr1["Column1"] = param1.ToString();
dr1["Column2"] = param2;
dr1["Column3"] = ht["testKey"].ToString();
ds.Tables[0].Rows.Add(dr1);
return ds;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用VS2005在C#中开发一个Windows应用程序.考虑我需要调用一个非静态方法(Method1),该方法位于另一个类(Class2)的类(Class1)中.为了调用该方法,我需要为该类创建对象.
但我的班级'Class1'有超过1000个变量.因此,每次我为'Class1'创建对象时,所有变量都会被实例化,但我的方法'Method1'使用的变量非常少.因此,不必要的所有其他变量都会被实例化.
我如何优化这段代码,因为它实例化了必须被调用的特定方法所不需要的变量.
或者是否有任何其他编码标准用于我可以克服这一点.提前致谢.
这是我的变量列表.编辑:
private string m_sPath = String.Empty;
private string m_sModule = String.Empty;
private string m_sType = String.Empty;
public static string strFileSave;
private string fileName = "", strFactoryXML = "", strPriorityXml = "", strTempXml = "";
private string selMethod = "";
private string selClass = "";
private string selMethodName = "";
private string str, str1, str2;
public static string strFolder;
public static string strFilePath = "";
public static string sel1, sel2;
private string strSetPrFileName = "";
private string …Run Code Online (Sandbox Code Playgroud) 考虑使用C#VS 2005构建的Windows应用程序在多行文本框中显示某些内容.现在,当我添加一些新文本时,它应该以不同的颜色显示.即我需要区分运行项目时显示的文本和我在文本框中输入的文本.我怎样才能做到这一点.?
我有一个矢量,其大小可能非常大(100万个元素).我将向量的内容写为文件作为字节值.我无法弄清楚如何将字节值读回到向量中.
这是代码:
#include <fstream>
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;
int main()
{
// Filling a vector with values
std::vector<bool> ve;
ve.push_back(true);
ve.push_back(false);
ve.push_back(true);
ve.push_back(false);
ve.push_back(true);
// Printing the values of the vector
for(unsigned int i = 0; i < ve.size(); i++)
cout << ve.at(i) << ".";
cout << endl;
// Writing the vector contents to a file
const char* file_name = "abc.txt";
ofstream outfile(file_name, ios::out | ios::binary);
outfile.write((const char*)&(ve[0]), ve.size());
outfile.close();
// Reading the file and …Run Code Online (Sandbox Code Playgroud) 我尝试了以下代码,但它没有用.
string tempStr;
tempStr[0] = 'a';
tempStr[1] = 'b';
tempStr[2] = 'c';
cout << "TempStr: " << tempStr << endl;
Run Code Online (Sandbox Code Playgroud)
输出给出一个空字符串.是因为,C++无法知道我的字符串结束的位置.所以它认为我的字符串是在声明中找到的0长度.
如果我尝试以下操作,我会输出"abc".
string tempStr = "xyz";
tempStr[0] = 'a';
tempStr[1] = 'b';
tempStr[2] = 'c';
cout << "TempStr: " << tempStr << endl;
Run Code Online (Sandbox Code Playgroud)
如何克服第一个代码中出现的问题?我应该使用字符或其他东西吗?