如何将1维String数组转换为String?

时间:2016-08-12 07:21:03

标签: vb.net

有一种简单的方法可以将一维String数组转换为普通String吗?我是vb.net的新手

2 个答案:

答案 0 :(得分:3)

如果您只想将项目粘合在一起(String.Concat),请尝试["A", "B", "CD"] -> "ABCD"

https://msdn.microsoft.com/en-us/library/dd784338(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

 Dim output As String = String.Concat(myArray);

如果您想分离数组的值(["A", "B", "CD"] -> "A, B, CD"),请尝试String.Join

https://msdn.microsoft.com/en-us/library/dd783876(v=vs.110).aspx

 Dim output As String = String.Join(", ", myArray);

答案 1 :(得分:1)

使用var myApp = angular.module('myApp', ['ngMaterial']); myApp.controller('autoCompleteController', function($scope) { $scope.selectedItems = []; $scope.querySearch = function() { return $scope.products.filter(p => p.name.toLowerCase().includes($scope.searchText)); }; $scope.AddInCart = function() { var itemName = $scope.selectedItem.name; var itemPrice = parseInt($scope.selectedItem.price); var itemQty = parseInt($scope.quantity); var totalPrice = parseInt(itemPrice * itemQty); var jsonCartItem = { 'name' : itemName, 'price' : itemPrice, 'qty' : itemQty, 'totAmt' : totalPrice }; $scope.selectedItems.push(jsonCartItem); console.log($scope.selectedItems); }; $scope.products = [ {name:"Worn Shortsword",price:3} ,{name:"Bent Staff",price:4} ,{name:"Worn Mace",price:3} ,{name:"Worn Axe",price:3} ,{name:"Revelosh's Armguards",price:4500} ,{name:"Revelosh's Spaulders",price:6725} ,{name:"Revelosh's Gloves",price:4534} ,{name:"The Shoveler",price:16164} ,{name:"Annealed Blade",price:12980} ]; });或者您希望加入他们。第一个参数就是您要加入的每个字符串之间的内容。使用vbCrLf换行。