是否有更好的方法将UDT转换为其他类型?

时间:2019-05-16 16:52:20

标签: vb.net user-defined-types boxing unboxing ctype

我有一个包含“值”属性的类,该“值”包含任何数据类型,因此是一个对象。在包含的示例中,“值”是类型“ nonNegativeInteger”。我需要能够将结构转换为两倍,而我发现唯一的方法就是笨拙:

import { Component, OnInit } from '@angular/core';
import { CartService } from '../services/cart.service';
import { ICartItem } from '../interfaces/ICartItem';

@Component({
  selector: 'app-cart',
  templateUrl: './cart.component.html',
  styleUrls: ['./cart.component.scss']
})
export class CartComponent implements OnInit {
  items: ICartItem[];

  ngOnInit() {

  }

  decreaseAmount(movie) {
    this.cartservice.removeMovie(movie);
  }
  increaseAmount(movie) {
    this.cartservice.addMovie(movie);
  }

  constructor(private cartservice: CartService) {
    this.cartservice.currentShoppingCart.subscribe( cart => {
      this.items = cart;
      console.log(this.items);
   });
      //This one will be undefined
      console.log(this.items);
  }
}

这是一个简单的vb Windows窗体项目中的代码:

CDbl(CTypeDynamic(obj, GetType(Double)))

0 个答案:

没有答案