Extend Method: String.AppendRight

Extend Method is a new attribute for C Sharp.

I like it for it just like loading some package with my arms as using extended method.


During my coding, i need to combine 2 string into a new one frequently.

And, Our "String" class does not offord one method like this append one string to another sting.

Everything i want this, i have to create a StringBuilder and make some combinings .......

A little and more garbage will reproduce....


Then, i get a new idea to extend string method:

public static string AppendRight(this String theOrginal, params String[] theattends)

{

StringBuilder stringbuild = new StringBuild(theOrginal);

foreach( String myString in theattends )

{

stringbuild.Append(myString);

}

return stringbuild.tostring();

}


Then, i can use it like this:

string one = "it is one".

one.AppendRight("yes","it is");

What i got is "it is oneyesit is".


COOL.

I like it.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我优化下 这段 js代码 我感觉写的好凌乱 variation(id, item, index) { console.log(index, ' index 124') console.log(id, ' 125') console.log(item, ' item') // 添加子元素 this.$api.mine.extendList({ id: id }).then((res) => { console.log(res.data.userExtendOne) if (this.treeData[index].child) { //push 1个人 if (res.data.userExtendOne && res.data.isLeader == 0) { console.log('1111') this.treeData[index].child.push({ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, ) } //push 2个人 if (res.data.userExtendOne && res.data.userExtendTwo && res.data.isLeader == 0) { console.log('2222') this.treeData[index].child.push({ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, { userExtendTwo: res.data.userExtendTwo, userTwo: res.data.userTwo }, ) } //push 3个人 console.log(res.data.isLeader, '150----') if (res.data.isLeader == 1) { console.log('3333') this.treeData[index].child.push({ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, { userExtendTwo: res.data.userExtendTwo, userTwo: res.data.userTwo }, { userExtendThree: res.data.userExtendThree, userThree: res.data.userThree }) } } else { //push 1 孩子的 孩子 if (res.data.userExtendOne) { this.$set(this.treeData[index], 'child', [{ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, ]) } //push 2 孩子的 孩子 if (res.data.userExtendOne && res.data.userExtendTwo) { this.$set(this.treeData[index], 'child', [{ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, { userExtendTwo: res.data.userExtendTwo, userTwo: res.data.userTwo }, ]) } //push 3孩子的 孩子 if (res.data.userExtendOne && res.data.userExtendTwo && res.data.userExtendThree) { this.$set(this.treeData[index], 'child', [{ userExtendOne: res.data.userExtendOne, userOne: res.data.userOne }, { userExtendTwo: res.data.userExtendTwo, userTwo: res.data.userTwo }, { userExtendThree: res.data.userExtendThree, userThree: res.data.userThree } ]) } } // this.treeData.push(this.removeDuplicates(this.treeData)) console.log("===data===" + JSON.stringify(this.treeData)) }) },
最新发布
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值